in reply to Re: How to save different format of images from webpages
in thread How to save different format of images from webpages

how to know the source image format...
  • Comment on Re^2: How to save different format of images from webpages

Replies are listed 'Best First'.
Re^3: How to save different format of images from webpages
by Anonymous Monk on Nov 22, 2010 at 00:59 UTC
    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.