EXIF (Exchangeable image information) data provide digital image metadata. This information is stored in the header of the image in JPEG or TIFF format. It can be very detailed (even thumbnails can be embedded) and is included in the file size of the image. In PHP web applications it is very easy to extract the available information, however, there are some prerequisites that need to be met.
EXIF extension is a standard part of PHP distributions, but it must be enabled in php.ini file in order to use its functions. On windows, EXIF extension also depends on mbstring, an extension that provides multi-byte string parsing. Moreover, the sequence of enabling extensions in php.ini file does matter. If exif is enabled prior to mbstring, EXIF functions will not be available at run-time.
mbstring extension must be enabled before EXIF!
If you need to use EXIF functions in your environment, be it development or production, this is something you need to keep in mind. By default, extensions are ordered in alphabetical order in php.ini file. This makes it very easy to run into situation when you start banging your head against the wall as you don’t realize why function_exists('exif_read_data') keeps returning FALSE even though you have enabled both EXIF and mbstring extensions. Recently I needed a quick setup of development environment on my laptop and downloaded WAMP server, probably the most popular WAMP stack available, and I run into the that situation.
I find it really awkward. Including extensions in alphabetical order does not make any sense when there are dependencies like this.
Comments and Trackbacks
Hi ,
i was searching for an article like this . I want to enable exif extension for a php project . From your article , i understood that i shud enable mbstring before exif. But , as a beginner , i dont know how to enable an extension in php. Im using Ubuntu 10.04
Pls help me
Hi Irfan,
thanks for your comment. I have published a separate article describing the procedure the modify PHP configuration and enable/disable extensions.
One Trackback
[...] same applies if order of extensions needs to be changed, as is the case in enabling PHP EXIF extension. This entry was posted in PHP commentscontact ussharebrowse [...]