Does anyone know all the possible results for the 3rd value returned from PHP's getimagesize() function? Example this code below will return:
$imageinfo['2'] = 2;
for ajpg
image,$imageinfo['2'] = 3;
for apng
image,$imageinfo['2'] = 0;
for agif
image.
The numbers might not be correct above but you get the idea.
I can't find on php.net or anywhere else a list of all possible results for the 3rd value.
$imageinfo = getimagesize($imageurl);
$image_type = $imageinfo['2'];
As previously mentioned constants which start with IMAGETYPE in get_defined_constants() list supported image types.
However, if you Just run this and it will tell you which ones are supported:
If you want to convert value returned by
getimagesize()
as index2
into something more human-readable, you may consider using a function like this one:Or something similar.
getimagesize
returns a value of one of the followingIMAGETYPE_*
constants.That index contains the value of one of PHP's IMAGETYPE_XXX constants. An entire list of them can be found on that page, towards the bottom. That page doesn't provide the actual INT value of each one but you should be able to print a few to get the values as necessary. You could also do a comparison check if you're looking for a specific one:
Execute this:
And then look for constants prefixed with IMAGETYPE_. On my PHP 5.3 installation I got these values:
As you can see Flash SWF are considered images, and actually
getimagesize()
is able to read the width and height of a SWF object. To me it seemed like a curiosity when I first discovered it, that's why mentioned it here.The above referred pages on the image constants only give the image constant names, not the integers stored in the image constants. The scripts above do give the integers, but I found a listing of the integers on an official PHP manual page at http://www.php.net/manual/en/function.exif-imagetype.php