Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: LWP to download images, how to let LWP decide, wether it is an image or not?

by Aristotle (Chancellor)
on Oct 20, 2001 at 08:12 UTC ( [id://120206]=note: print w/replies, xml ) Need Help??


in reply to LWP to download images, how to let LWP decide, wether it is an image or not?

I've made a Photo Gallery sort of site before, so I know the kind of problem you have. Unfortunately even MIME types cannot really be trusted (esp not from browser uploads either). The only proper solution is to consciously restrict your service to certain image formats (say GIF JPEG PNG; and probably also a maximum filesize) and then use a tool or module to verify the file as a valid GIF/JPEG/PNG after fetching it. (I have used Image::Magick for that before.)
  • Comment on Re: LWP to download images, how to let LWP decide, wether it is an image or not?

Replies are listed 'Best First'.
Re: Re: LWP to download images, how to let LWP decide, wether it is an image or not?
by uwevoelker (Pilgrim) on Oct 20, 2001 at 17:12 UTC
    I like the idea of verifying the file format. You could use Image::Size to check for pictures. And maybe you need the filesize for the HTML-img-Tag (width and height).

    Also I would open the OUTFILE right before the PRINT-statement. If the picture is not valid you end in having created a zero-length file.

    Good bye, Uwe

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://120206]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-26 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found