Rate this script:  I Love it  /   I Hate it

PHP Exif Reader Demo


Code


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Extract Exif-Data Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>

<?php



   function printExif($fileName)
   {
      // Written in 2007 by Sascha Tayefeh
      // http://www.tayefeh.de
      // This code is FREE for all
      if(function_exists('exif_read_data'))
      echo "exif library present";
      else
      echo "exif library absent";

      $exifDat=@exif_read_data($fileName);

      $myExif=array(
         "FocalLength" => "Focal Length",
         "ISOSpeedRatings" => "ISO",
         "ExposureTime" => "Shutter",
         "Make" => "Manufacturer",
         "Model" => "Model",
         "Software" => "Software",
         "FNumber"      => "Focal Number",
         "Country"      => "Country",
         "Lens" => "Lens",
         "LensId"       => "Lens Id"
      );

      if($exifDat)
      {
         foreach ($myExif as $key => $value)
         if(isset($exifDat[$key]) && $exifDat[$key])
            echo "<br/><strong>$value</strong>: ".$exifDat[$key];

         if($exifDat['COMPUTED']['ApertureFNumber'])
            echo "<br /><strong>Aperture</strong>: ".$exifDat['COMPUTED']['ApertureFNumber'];   

         if($exifDat['Flash']) echo "<br/><strong>Flash</strong>: shot";
         else echo "<br/><strong>Flash</strong>: not shot";

         if($exifDat['DateTimeOriginal'])
         {
            $myDate[1]=explode(' ',$exifDat['DateTimeOriginal']);
            $myDate[0]=explode(':',$myDate[1][0]);

            echo "<br/><strong>Date</strong>: ".$myDate[0][2]."-".$myDate[0][1]."-".$myDate[0][0];
            echo "<br/><strong>Time</strong>: ".$myDate[1][1];
         }

      }
   } // End Function

   if (!isset($_POST['go']))
   {
   ?>
   <h1>Extract some Exif-Data from file</h1>
   <form        enctype="multipart/form-data"
action="<? echo $_SERVER['PHP_SELF']; ?>"
method="post"
>
<dl>
<dt>ImageFile URL:</dt>
<dd><input type="file" name="imgFile" size="40" /></dd>
<dt>&nbsp;</dt>
<dd><input type="submit" value="Start Upload (may take a while)" /></dd>
</dl>
<input style="display: none" name="go" value="analyse" />
</form>
<?
   } else {
   ?>
   <h1>Exif-Data:</h1>
   <?
   $img=$_FILES['imgFile']['tmp_name'];
   printExif($img);
?>

<?
   } // END IF POST
?>

</body>
</html>

 

 

 
PHP Exif Reader Demo scripts | PHP Exif Reader Demo snippet | PHP Exif Reader Demo example | PHP Exif Reader Demo tutorial | PHP Exif Reader Demo code