#!/usr/bin/perl use GD; $strct = $ENV{'QUERY_STRING'}; $numdigits = length($strct); # figure out how many digits there are @digary = split(//,$strct); # split it into an array of single digits $tmp = GD::Image->newFromPng("img/0.png"); # read in the 0, just to get the height # and width information. ($width,$height) = $tmp->getBounds; # for now, make a guess about the total width of the image. $maxwidth = $width * ($#digary + 1); # create a temp image for storing the counter $myimg = new GD::Image($maxwidth,$height); # counter for the actual width $acwidth = 0; # now fill the temp image with the digits foreach $i (@digary) { $tmp = GD::Image->newFromPng("img/$i.png"); # read in that digit's image; ($tmpx,$tmpy) = $tmp->getBounds; # get its width/height $myimg->copy($tmp,$acwidth,0,0,0,$tmpx,$tmpy); # copy to temp counter $acwidth = $acwidth + $tmpx; # increment width } # now create the final counter with the appropriate height/width $dimg = new GD::Image($acwidth,$height); # copy the tmp counter to the final one $dimg->copy($myimg,0,0,0,0,$acwidth,$height); # make the final image interlaced $dimg->interlaced(1); # convert it to a GIF $img_data = $dimg->png; # now print it out print "Content-type:image/png\n\n"; binmode(STDOUT); print $img_data;