AAA Главная
Примеры PHP Примеры JavaScript Примеры Ajax Примеры CSS,HTML

Пример чтения EXIF данных из файла jpeg

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 "
<strong>$value</strong>: ".$exifDat[$key];
 
         if($exifDat['COMPUTED']['ApertureFNumber'])
            echo "
<strong>Aperture</strong>: ".$exifDat['COMPUTED']['ApertureFNumber'];   
         if($exifDat['Flash']) echo "
<strong>Flash</strong>: shot";
         else echo "
<strong>Flash</strong>: not shot";
 
         if($exifDat['DateTimeOriginal'])
         {
            $myDate[1]=explode(' ',$exifDat['DateTimeOriginal']);
            $myDate[0]=explode(':',$myDate[1][0]);
 
            echo "
<strong>Date</strong>: ".$myDate[0][2]."-".$myDate[0][1]."-".$myDate[0][0];
            echo "
<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="<?=$_SERVER['PHP_SELF'];?>" method="post">
<dl>
<dt>ImageFile URL:</dt>
<dd><input type="file" name="imgFile" size="40" /></dd>
<dt> </dt>
<dd><input type="submit" value="Start Upload (may take a while)" /></dd>
</dl>
<input style="display: none" name="go" value="analyse" />
</form>
<?
} else {
   echo "<h1>Exif-Data:</h1>\n";
   $img=$_FILES['imgFile']['tmp_name'];
   printExif($img);
} // END IF POST

. Работа Дизайн интерьера в Москве mankaraya.ru.

© Copyright 2008-2016 by KDG