Reading EXIF Data From Images in PHP
EXIF stands for Exchangeable image file format is standard by which metadata is stored in image & sound file formats, these are sometimes added by digital camera / software / or manually added by a user. These standards metadata tags help people track / store info, for example Flickr shows the camera used to take the photo using the EXIF tags, and allows you to see all images taken using a specific make/model, thereby helping in cataloguing the photos.
In this article I'll be showing what you would need to read EXIF info from images, and how to go about doing it, and a example practical usage of it.
To enable EXIF support you'll need to configure PHP with --enable-exif, and in case you are using Windows you'll need to enable php_exif.dll and php_mbstring.dll in php.ini, and also make sure that php_mbstring.dll loads before php_exif.dll.
With a handful of functions provided by the EXIF extension you can detect image format, get specific tags, like thumbnails and other, or read them all at once. The example below will help you understand the usage of the functions:
An example practical application would be where where the image is automatically rotated by the script using the orientation information provided in the EXIF, see the example below:
Now, the image will be rotated automatically, refer to http://sylvana.net/jpegcrop/exif_orientation.html for the list of orientation values.
Re: Reading EXIF Data From Images in PHP
Thank you , i update my upload forms. I use few functions to check if an image is really a valid image but this is something that will prevent future attacks. Actually few hosters have a strict file checking but this is made by checking file extension in most of the cases.
|All times are GMT +5.5. The time now is 08:04.|