\n"; echo "Thumbnail could not be extracted.\n"; echo "
"; } die(); } if ( !defined('IMAGETYPE_GIF')) define('IMAGETYPE_GIF',1); if ( !defined('IMAGETYPE_JPEG')) define('IMAGETYPE_JPEG',2); if ( !defined('IMAGETYPE_TIFF_II')) define('IMAGETYPE_TIFF_II',7); if ( !defined('IMAGETYPE_TIFF_MM')) define('IMAGETYPE_TIFF_MM',8); $possible = array(); /****************************************************************************/ // message function is used for debugging purpose: just to se what happens function message($msg) { error_log($msg,0); echo "$msg\n"; } function error_msg() { $ret = 'O.K.'; if (array_key_exists('php_errormsg',$GLOBALS) && strlen($GLOBALS['php_errormsg'])) { $ret = ''.$GLOBALS['php_errormsg'].''; $GLOBALS['php_errormsg'] = ''; } return $ret; } /****************************************************************************/ // private to function search_file() function _search_file($root,&$possible,$path='') { $sub = array(); $cnt = 0; $type= false; //error_log("search_file($root,$path)",0); if ($dir = @opendir($root.$path.'/')) { while (($found = @readdir($dir)) !== false) { $type = @filetype($root.$path.'/'.$found); //error_log("search_file($root$path):$type=$found",0); switch( $type) { case 'file': $pos = strrpos($found,'.'); if ( function_exists('exif_imagetype')) { $type = exif_imagetype($root.$path.'/'.$found); } else { if ( $pos!==false) { $type = GetImageSize($root.$path.'/'.$found); if ( is_array($type)) { $type = $type[2]; } else { $type = false; } } else $type = false; } if ( $type!==false) { $possible[] = array('file'=>$root.$path.'/'.$found, 'type'=>$type); //error_log("search_file($root$path) add:$path/$found",0); if ( ($cnt=count($possible)) % 100 == 0) { error_log("exif test page - counting files: $cnt",0); } } break; case 'dir': if ( $found!='.' && $found!='..') { $sub[count($sub)] = $found; } break; } } @closedir($dir); foreach( $sub as $idx => $found) { _search_file($root,$possible,$path.'/'.$found); } } } /****************************************************************************/ // function: search_file($file,$ext) // // Searches for $file in document tree. The path is ignored. // function search_file() { global $argc, $argv; $possible = array(); if ( $argc > 1) { $path = $argv[1]; } else if ( array_key_exists('SCRIPT_FILENAME',$_SERVER)) { $path = $_SERVER['SCRIPT_FILENAME']; //error_log("SCRIPT_FILENAME($path)",0); } else { $path = $argv[0]; //error_log("argv($path)",0); } if ( ($p=strpos($path,'?')) !== false) $path = substr($path,0,$p); if ( ($p=strrpos($path,'/')) /*< strlen($path)-1*/) $path = substr($path,0,$p); error_log("exif test page - counting files in $path"); _search_file($path,$possible); error_log("exif test page - counting files: ".count($possible)." done.",0); return $possible; } /****************************************************************************/ // function: search_file($file,$ext) // // Searches for $file in document tree. The path is ignored. // function AddInfo($Name,$Value,$highlight=0) { if (is_array($Value)) $Value = 'Array: ('.join(',',$Value).')'; $Value = nl2br($Value); if ( $highlight) { $Name = "$Name"; } else { $Name = "$Name"; } return "$Name$Value \n"; } $possible = search_file(); $title = "PHP module exif test page"; ?> <?=$title ?>

(c) Marcus Börger, 2002

Images taken from www.exif.org, marcus-boerger.de all rights reserved by their authors and artists, see exif headers. The files can be downloaded here. To start the test you simple have to put all images into the same directory as this script. The test will work with all files in that directory and all subdirectories. To test private images just put them into that directory.

Youmay take a look at the test source here.

This test just prooves that some exif headers can be scanned. If all files produce a header in output the module might be o.k.

What to look for in detail:

function exif_tagname

\n"; } ?>
ImageWidth
JPEGProc
SceneType
false
function exif_tagname is not supported

function exif_read_data for images

\n"; $tab2 = "";//"\n"; $types = array('','GIF','JPEG','PNG','SWF','PSD','BMP','TIFF_II','TIFF_MM','JPC','JP2','JPX','JB2'); foreach($possible as $idx => $file) { $type = $file['type']; $file = $file['file']; if ( !((++$num)%100)) error_log("exif test page - checking files: $num",0); $error = ''; $len = 2; $rows = 1 + ($check_getimagesize ? 1 : 0) + ($check_exif_thumbnail ? 1 : 0) + ($check_exif_read_data ? 1 : 0); if ( !$fast_output) echo "\n"; if ($check_getimagesize) { $len++; $size = GetImageSize($file); $error = error_msg();// clear message if ( $size === false) { $error = 'GetImageSize returned false
'.$error; $res_getimagesize = $error; } else { $res_getimagesize = '('.join($size,',').')'; } if ( !$fast_output) echo AddInfo("GetImageSize",$error,1); } if ( $check_exif_thumbnail) { $len++; if ($type!=IMAGETYPE_JPEG) {// && $type!=IMAGETYPE_TIFF_II && $type!=IMAGETYPE_TIFF_MM) { $error = "filetype not supported: $types[$type]"; $res_exif_thumbnail = $error; } else { $t_width = 0; $t_height = 0; $result = exif_thumbnail($file, $t_width, $t_height); $error = error_msg();// clear message if ( $result === false) { $error = 'exif_thumbnail returned false
'.$error; if ( $t_width && $t_height) { $error = "$t_width x $t_height
$error"; } $res_exif_thumbnail = $error; } else { $res_exif_thumbnail = $t_width . " x " . $t_height; } } if ( !$fast_output) echo AddInfo("exif_thumbnail",$error,1); } if ($check_exif_read_data) { $len++; if ($type!=IMAGETYPE_JPEG && $type!=IMAGETYPE_TIFF_II && $type!=IMAGETYPE_TIFF_MM) { $res_exif_read_data = "filetype not supported: $types[$type]"; if ( !$fast_output) echo AddInfo("exif_read_data",$res_exif_read_data); $res = ''; } else { $image = exif_read_data($file,'COMMENT,IFD0,EXIF,APP12',true); $error = error_msg();// clear message if ( !$fast_output) echo AddInfo("exif_read_data",$error,1); $res = ''; if ( $image === false) { $res_exif_read_data = "exif_read_data returned false
$error"; } else { $res_exif_read_data = $error; // ah no!$error = error_msg(); // force o.k. foreach($image as $Name => $Value) { if ( $Name!='Thumbnail') { if ( is_array($Value)) { $len++; $res .= AddInfo($Name,'Array('.count($Value).')'); foreach( $Value as $idx => $Entry) { if ($idx==='Thumbnail') $Entry = '<data>'; $len++; $res .= AddInfo($Name.':'.$idx,$Entry); } } else { $len++; $res .= AddInfo($Name,$Value); } } } } } } $tab2 .= "\n"; $tab2 .= "\n"; if ($check_getimagesize) { $tab2 .= "\n"; } if ($check_exif_thumbnail) { $tab2 .= "\n"; } if ($check_exif_read_data) { $tab2 .= "\n"; $tab2 .= $res; } if ( $fast_output) { echo $tab2; $tab2 = ''; } } error_log("exif test page - checking files: ".count($possible)." done.",0); echo $tab2; echo "
$num$file
$num
$file
GetImageSize$res_getimagesize
exif_thumbnail$res_exif_thumbnail
exif_read_data$res_exif_read_data
\n"; } else { echo "

function exif_read_data is not supported

\n"; } ?>