http://www.perlmonks.org?node_id=259732

wil has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm having some problems outputting the results of Image::Magick to a web browser. I can output to a file and it works just fine, but for some reason I get the following error when trying to output to a browser window. My code follows.

my $self = shift; my $q = $self->query(); my $image_path = $q->param('image'); $self->header_props ( -type =>'image/png', ); my ($image,$x); my $image = Image::Magick->new(); $x = $image->Read(filename =>"/images/users/$image_path"); $x = $image->Resize(geometry =>'175x275'); # THIS DOES NOT WORK - WHY? binmode STDOUT; $x = $image->Write(.png:-'); # THIS WORKS PERFECTLY: # $x = $image->Write(filename =>'/images/users/resize/test.png');
Error:
The image “http://phoenix/foo.pl?rm=th_show_user;image=481_img-home2.j +pg” cannot be displayed, because it contains errors.


- wil