Working with Image Metadata in PHP

Sometimes you want to extract the descriptive information embedded in an image, such as the metadata or thumbnails placed in digital photos. For this, you can use PHP’s Exchangeable Image File Format (EXIF) functions. EXIF is a standard for storing descriptive metadata in image files, particularly JPEG and TIFF files.

PHP’s exif_read_data() function can read these headers and extract the information stored within them. below is an example code which extract the information embed in an image.

  1. <?php
  2. $DIR = “C:/Users/laeeq/Pictures/”;
  3. $filelist = glob(“$DIR/*.jpg”);
  4. if(sizeof($filelist)>0) {
  5. foreach($filelist as $file) {
  6. $exif = exif_read_data($file, 0, true);
  7. echo “File: $file \n”;
  8. foreach($exif as $section => $data) {
  9. foreach($data as $key => $value) {
  10. echo “$section -> $key = $value \n”;
  11. }
  12. }
  13. echo “\n”;
  14. }
  15. }
  16. ?>


A web developer who has a love for creativity and enjoys experimenting with various techniques in both web design and development. If you would like to be kept up to date with our posts, you can follow us on Twitter, or even by subscribing to our RSS Feed.

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera