in reply to How to save different format of images from webpages

ajju:

Just save the image with the extension that matches the source image, rather than forcing a .jpg on the end.

...roboticus

  • Comment on Re: How to save different format of images from webpages

Replies are listed 'Best First'.
Re^2: How to save different format of images from webpages
by ajju (Initiate) on Nov 21, 2010 at 22:30 UTC
    how to know the source image format...
      Either the url tells you, or the headers tell you, or nothing tells you and you have to guess

      LWP::MediaTypes, File::MMagic

      $ ls -loanh *.gif -rw-rw-rw- 1 0 53 2010-09-17 23:39 working.gif $ perl -MWWW::Mechanize -le" $ua = WWW::Mechanize->new; $ua->get('file +:working.gif'); die $ua->ct; " image/gif at -e line 1. $ perl -MWWW::Mechanize -MLWP::MediaTypes=media_suffix -le" $ua = WWW: +:Mechanize->new; $ua->get('file:working.gif'); die media_suffix( $ua- +>ct ); " gif at -e line 1.