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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to