How to Use the PHP Function Exif_ImageType
If you want to work with Exif data in PHP (Metadata of image files) you may need the php function exif_imagetype. But when you try to use it you get the error: call to undefined function exif_imagetype(). So what's the solution?
This article will show you how to solve the issue.
The php function exif_imagetype reads the first bytes of an image file and checks its signature. When a correct signature is found a constant value will be returned, else FALSE. The constants are: 1 = IMAGETYPE_GIF, 2 = IMAGETYPE_JPG, 3 = IMAGETYPE_PNG, 4 = IMAGETYPE_SWF, 5 = IMAGETYPE_PSD, 6 = IMAGETYPE_BMP, 7 = IMAGETYPE_TIFF_II (intel byte order), 8 = IMAGETYPE_TIFF_MM (motorola byte order) and 9 = IMAGETYPE_JPC.
It can be used to avoid calls to other exif functions with unsupported file teypes or in conjunction with $_SERVER['HTTP_ACCEPT'] to check whether an image is allowed in the web browser.