Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

LWP::UserAgent Image Corruption

by DST609 (Novice)
on Dec 30, 2012 at 18:42 UTC ( #1010953=perlquestion: print w/ replies, xml ) Need Help??
DST609 has asked for the wisdom of the Perl Monks concerning the following question:

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");

Comment on LWP::UserAgent Image Corruption
Select or Download Code
Re: LWP::UserAgent Image Corruption (LWP DOES NOT CORRUPT IMAGES)
by Anonymous Monk on Dec 31, 2012 at 02:55 UTC

    This would lead me to believe that the image is not saving correctly.

    LWP does not corrupt images, end of story :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1010953]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2014-07-28 04:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (186 votes), past polls