Working with Image Metadata in PHP

March 27th, 2013 by Laeeq | No comments

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. ?>

You can subscribe to PHPZAG.COM posts by Email

 

Related Topics:

  • Parse HTML/Web Pages with PHP
  • Block Multiple IP Addresses Using PHP
  • How much memory do PHP variables use?
  • Manipulating PHP arrays: push, pop, shift, unshift
  • 10 Super Useful PHP Code Snippets
  •  

     

    1. No comments yet.
    1. No trackbacks yet.