I wrote the following script to retrieve images (runs in loop), save and resize however I am getting the following error in image magick when reading the downloaded image:

Exception 450: Unsupported marker type 0x54

If I download the LWP downloaded image to my computer, open it in a photo editor, re-save as .jpg, upload-overwrite and attempt to read with imagemagick all is fine. This would lead me to believe that the image is not saving correctly. I need to use UserAgent because the server I am connecting to won't allow the download unless it thinks a client is requesting the data.
use LWP::UserAgent; use Image::Magick; $ua = new LWP::UserAgent; $ua->agent("$0/0.1 " . $ua->agent); $ua->agent("Mozilla/8.0"); my $PICURL ="http://www.example.com/img.axd?pid=cjfsaf79afffafhfah77"; my $PICDEST="/var/vhosts/mysite.com/httpdocs/images"; my $PICNAME="01.jpg"; my $response = $ua->get("$PICURL"); open(outfile, ">:raw", "$PICDEST/$PICNAME"); binmode outfile; if ($response->is_success) { print outfile $response->content; $Pi++; $PTOT++; } else { die $response->status_line; } $image = new Image::Magick; $image->Read("$PICDEST/$PICNAME"); $image->Scale(width=>800, height=>600); $image->Write("$PICDEST/$PICNAME"); $image->Scale(width=>216, height=>163); $image->Set(quality=>90); $image->Write("$PICDEST/TH_$PICNAME");

In reply to LWP::UserAgent Image Corruption by DST609

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.