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 a jpg
image,$imageinfo['2'] = 3;
for a png
image,$imageinfo['2'] = 0;
for a gif
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'];
The getimagesize() function in PHP is an inbuilt function which is used to get the size of an image. This function accepts the filename as a parameter and determines the image size and returns the dimensions with the file type and height/width of image.
You will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with. You can use the image functions in PHP to get the size of JPEG, GIF, PNG, SWF, TIFF and JPEG2000 images.
The imagesx() and imagesy() are used to extract the width and height of the images respectively.
Execute this:
print_r(get_defined_constants());
And then look for constants prefixed with IMAGETYPE_. On my PHP 5.3 installation I got these values:
[IMAGETYPE_GIF] => 1
[IMAGETYPE_JPEG] => 2
[IMAGETYPE_PNG] => 3
[IMAGETYPE_SWF] => 4
[IMAGETYPE_PSD] => 5
[IMAGETYPE_BMP] => 6
[IMAGETYPE_TIFF_II] => 7
[IMAGETYPE_TIFF_MM] => 8
[IMAGETYPE_JPC] => 9
[IMAGETYPE_JP2] => 10
[IMAGETYPE_JPX] => 11
[IMAGETYPE_JB2] => 12
[IMAGETYPE_SWC] => 13
[IMAGETYPE_IFF] => 14
[IMAGETYPE_WBMP] => 15
[IMAGETYPE_JPEG2000] => 9
[IMAGETYPE_XBM] => 16
[IMAGETYPE_ICO] => 17
[IMAGETYPE_UNKNOWN] => 0
[IMAGETYPE_COUNT] => 18
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With