Saturday, November 8, 2008

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 = '';
$size = getimagesize( $url );

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


Alec said...

Very useful! Thanks!

DieGoth 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.

Joop Doop said...

Totally agree with your suggestion.. Very nice post and good information here..Thanks for posting that.. Read here

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...