exif-test3.php to HTML

index

USE AT OWN RISK

Generated: Tue Jul 31 15:21:59 2007 from exif-test3.php 2005/11/01 2.4 KB bytes.




<?
$meol = "\r\n";
$add_exif = 0;
ob_start();

echo '<html>
<head>
<title>Exif-test3<title>
<meta http-equiv="Content-Type" content="text/html">
</head>
<body>';
//header("Content-type: image/jpeg");
//echo "<h1 align='center'>Test for embedded thumbnail images ...</h1>$meol";
$in_dir = "/homepage/russ9/images/page17/.";
$d = dir($in_dir);
while($entry = $d->read()) {
   $locpath = substr($in_dir,0,(strlen($in_dir)-1)).$entry;
   //echo "Got item $locpath ...<br>$meol";
 if (($entry != ".") && ($entry != "..")) {
   if (is_file($locpath)) {
   //echo "Storing $entry ...<br>$meol";
   $filelist[] = $entry;
   } else {
   //echo "Is NOT a file ... <br>$meol";
   }
   } else {
   //echo "Just dot or double dot ...<br>$meol";
   }
}
$d->close();
$count = 0;
if (isset($filelist)) {
   foreach ($filelist as $fil) {
   $locpath = substr($in_dir,0,(strlen($in_dir)-1)).$fil;
   $parts = split("\.",$fil);
   $ext = $parts[count($parts)-1];
   $thumb_name = array_slice($parts,0,count($parts)-1);
   $file_name = implode("", $thumb_name);
   $ext = strtolower($ext);
   if ($ext == "jpg") {
   $count++;
   //$thumb_data = exif_thumbnail($locpath);
   $thumb_data = exif_thumbnail($locpath, $width, $height, $type);
   if ($thumb_data) {
   $mt = image_type_to_mime_type($type);
   //echo "$locpath CONTAINS thumb data ... $width x $height ... mime = $mt <br>$meol";
   ob_start();
   header('Content-type: ' . image_type_to_mime_type($type));
   //print ($thumb_data);
   print (imagejpeg($thumb_data));
   ob_end_flush();
   $image = $locpath;
   //echo("<A href=showthumb.php?image=" . $image .
   //   "><IMG border=0 src=showthumb.php?image=" . $image ."></A><BR>$meol");
   if ( $add_exif ) {
   $exif = exif_read_data($image, 'ANY_TAG',true);
   if (!$exif===false) {
   echo("Image contains headers<br>$meol");
   foreach ($exif as $key => $section) {
   foreach ($section as $name => $val) {
   echo "$key.$name: $val<br>$meol";
   }
   }
   } else {
   echo("Sorry, image <B>".$image . "</B> does not contain (readable) EXIF data.");
   }
   }
   } else {
   echo "$locpath DOES NOT CONTAINS thumb data ...<br>$meol";
   }
   } else {
   echo "$locpath is NOT a jpg file ...<br>$meol";
   }
   if ($count == 1)
   break;
   }
} else {
   echo "WARNING: Failed to find any files in $in_dir ...<br>$meol";
}

echo '</body></html>';

ob_end_flush();

?>

index

Valid HTML 4.01 Transitional