So you're trying to show an image in your browser with a perl script ..
remember that you're not allowed to send a single byte extra besides the image data + it's mime type .. so the browser knows how to interpretate it..
Read an image (png and output as jpeg):
$oCGI = new CGI;
print $oCGI->header( -type => "image/png", -expires => "now" );
my $oImageMagick = new Image::Magick( format => "png" );
$oImageMagick->Read( filename => "/some/imagefile.png" );
$oImageMagick->Write( "png:-" );
It's from the top of my head, so could not work right away