Okay I'm using Image::Magick to resize some images to thumbnails. I thought about using GD but I will probably be adding functions to this app later that GD can't do.

Anyway reading the original, resizing and writing the new image to a new file all works just fine but after I've done this I can no longer write to STDOUT and subsequently the webserver throws a 500 error because it doesn't receive any output from the program.

I tried selecting STDOUT ( select STDOUT) but it still didn't work. However when I did:

print STDOUT "Output blah blah ...";

It works but I feel its kind of ugly. Any ideas on being able to default back to STDOUT (am I doing something wrong?).

Here's the code in question for those interested.

my $image = Image::Magick->new; open(IMAGE,"$path") or upload_failed("Couldn't open $path for reading" +,$path); $image->Read(file=>*IMAGE); close(IMAGE); $image->Resize(width=>$conf->thumb_width,height=>$conf->th +umb_height); open(THUMB,">$thumbs/thumb_$filename") or upload_failed("Couldn't open + thumbnail file: $!",$path); $image->Write(file=>*THUMB,filenam +e=>"$thumbs/thumb_$filename"); close(THUMB); # no longer can write to STDOUT from this point on. works if # I delet +e the line $image->Write ....

Chris

Some clever or funny quote here.

In reply to Weird problems with Image::Magick and STDOUT by cfreak

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.