What kind of file types does PHP getimagesize() re

2020-06-10 06:27发布

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'];

7条回答
迷人小祖宗
2楼-- · 2020-06-10 07:08

Quoting the manual :

Index 2 is one of the IMAGETYPE_XXX constants indicating the type of the image.

And you can find those constants onh this page, amongst the other defined by GD

查看更多
登录 后发表回答