PHP Image Info Function. View Exif info of Images

Oct 26th, 2011

Using PHP information function, you can write small script to review your camera setting at the time of image capture. Here is small script to view images in a folder with few important settings.

Sample Output:

php-image-info

If you want more information for each image then un-comment the line (//print_r($exif['EXIF']);) and use the key available there.

Folder Structure:

gallary

File::thumbnail.php

<?php
// define directory path
$dir = "./imgs";
$image = exif_thumbnail($dir . "/" . $_GET['file']);
header("Content-Type: image/jpeg");
echo $image;
?>

 

File::gallary.php

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

	function div($n) {

		$x = explode('/', $n);
		$val = ($x[0]/$x[1]);

		return  $val ;

	}
?>
<html>
<head>
<title>Gallary </title>
</head>
<body>
<table>
<?php
// define directory path
$dir = "./imgs/";

// iterate through files
// look for JPEGs
if (is_dir($dir)) {
	if ($dh = opendir($dir)) {

	while (($file = readdir($dh)) !== false) {

		if (preg_match("/.jpg/i", $file)) {
			// read EXIF headers
			$exif = exif_read_data($dir.$file, 0, true);
			echo "<tr>";
			// get thumbnail
			// link to full image
			echo '<td valign=top><a href="' . "$dir$file" . '"><img src="thumbnail.php?file='. $file .'" /></a><td>';
			echo "<td valign=top><font size=-1>";

			//print_r($exif['EXIF']);
			// get file name
			echo "File: <b>" . $exif['FILE']['FileName'] . "</b><br/>";

			echo "ExposureTime: "  . $exif['EXIF']['ExposureTime'] . "<br/>";

			echo "FNumber: f "  .  div($exif['EXIF']['FNumber']) . "<br/>";

			echo "ISOSpeedRatings: "  . $exif['EXIF']['ISOSpeedRatings'] . "<br/>";

			echo "FocalLength: "  . div($exif['EXIF']['FocalLength']) . "<br/>";

			echo "Flash: "  . $exif['EXIF']['Flash'] . "<br/>";

			// get camera make and model
			//echo "Camera: " . $exif['IFD0']['Model'];
			echo "</font></td>";
			echo "</tr>";
		}
	}
closedir($dh);
}
}
else {
	echo 'Dir read fail';
}
?>
</table>
</body>
</html>

 
Possibly Related posts:
  1. No comments yet.
  1. No trackbacks yet.

All comments will be moderated.

Mobify empowers marketers and developers to create amazing mobile web experiences. Tap to learn more

Mobify