|
Posted by Richard Davey on 10/12/05 13:24
Hi Tommy,
Wednesday, October 12, 2005, 10:48:55 AM, you wrote:
> Is it possible to check if an url is a jpg image from php?
#1 Quick and unreliable: Check if there is a .jpg or .jpeg as the final
characters of the URL string.
#2 Bit more complex, very expensive: fopen() the URL, download the
content to a temporary location, inspect it with native php functions
like getimagesize. If your PHP config allows, you can probably perform
a getimagesize directly on the URL, but I've not tried this.
#3 Trickier, less expensive than #2, but balls-on accurate: fopen()
the URL (after suitable validation) and grab the header (the first few
KB). JPEG files are easily identified, but come in a variety of
flavours.
http://www.codeproject.com/bitmap/iptc.asp
Cheers,
Rich
--
Zend Certified Engineer
http://www.launchcode.co.uk
[Back to original message]
|