PHP: Get remote image properties

Below is an example of how to get the image properties from a remote server/website using getimagesize() function of PHP.

$url = 'http://static.php.net/www.php.net/images/php.gif';
$size = getimagesize( $url );
print_r($size);


The output for the above script will return image width, height, type, etc as below.
Array
(
[0] => 120
[1] => 67
[2] => 1
[3] => width="120" height="67"
[bits] => 7
[channels] => 3
[mime] => image/gif
)

Comments

Alec said…
Very useful! Thanks!
D. said…
Not so useful if your server has the url remote access disabled (95% of the time).
Urdu said…
it doens't work. it works perfectly for local files.
Paul Harris said…
Problem with getimagseize is,if remote image is very large and we try to fetch image properties with this method using php,it exceeds to php script running time and doesn't get the image properties and hard part is,there is no alternative to getimagesize which will get image properties from remote location instead of first downloading it.
Unknown said…
Totally agree with your suggestion.. Very nice post and good information here..Thanks for posting that.. Read here