16.1. Analyzing Images

These functions read information from images.

integer exif_imagetype(string file)

The exif_imagetype function reads the first few bytes of an image file and returns the type as an integer. Table 16.1 lists image types recognized. If PHP cannot determine the type, it returns FALSE.

Table 16.1. Image Types
ConstantDescriptionFile Extension
IMAGETYPE_BMPWindows Bitmap.bmp
IMAGETYPE_GIFGraphic Interchange Format.gif
IMAGETYPE_IFFInterchange Format Files.iff
IMAGETYPE_JB2Joint Bi-level Image Experts Group.jb2
IMAGETYPE_JP2JPEG 2000.jp2
IMAGETYPE_JPCJPEG 2000.jpc
IMAGETYPE_JPEGJoint Photographic Experts Group.jpg
IMAGETYPE_JPXJPEG 2000.jpx
IMAGETYPE_PNGPortable Network Graphics.png
IMAGETYPE_PSDAdobe Photoshop.psd
IMAGETYPE_SWCMacroMedia ...

Get Core PHP Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.