in reply to ascii art trouble
As a footnote to your original problem, you might consider reducing the size of the html generated by wrapping consecutive runs of pixels of the same color in a single set of FONT tags, rather than each pixel individually.
Using a very simple 17x11 printer icon in two colors, this reduced the size of the html from 6,039 bytes to 1,587. And on a moderately complex picture, 128x96 pixels it reduced from 360,870 bytes to 89,270.
Remove the two comment cards from the following version of your code to see one way of acheiving this.
#! perl -sw use strict; #$| = 1; use GD; use CGI ":all"; my $im = GD::Image->newFromPng("m.png"); my ($width, $height) = $im->getBounds(); my $result; for my $y (0 .. $height) { $result .= "<BR>\n"; for (my $x=0; $x < $width; $x++) { my $color = $im->getPixel($x, $y); my $n=1; # ++$n while $color == $im->getPixel(++$x, $y) and $x <= $width +; $result .= font( { color=> sprintf "%02x%02x%02x", $im->rgb($c +olor) } ,'#' x $n ); # --$x; } } print header,$/; print substr($result, $_*60000, 60000) for 0 .. int(length($result)/60 +000); print end_html;
|
---|