Re: Check if an url is a jpg image

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux