--- expose/index.php 2003/11/05 15:40:21 1.4 +++ expose/index.php 2003/11/06 11:47:12 1.5 @@ -20,7 +20,7 @@ | Version 2 along with this program; if not, visit GNU's Home Page | http://www.gnu.org/ +----------------------------------------------------------------------+ -$Id: index.php,v 1.4 2003/11/05 15:40:21 cam Exp $ +$Id: index.php,v 1.5 2003/11/06 11:47:12 cam Exp $ */ $global_var['metadata']['author'] = "Carl Johan Schedvin "; @@ -62,6 +62,16 @@ $global_var['image_sz']['default'] =& $global_var['image_sz']['640']; +$global_var['exif'] = array ( + 'Make', + 'ApertureFNumber', + 'FocalLength', + 'DateTime', + 'FlashMode' + ); +$exif_headers = array (); + + if(isset($_SERVER['PHP_SELF'])) { $php_self = $_SERVER['PHP_SELF']; } else { @@ -85,6 +95,57 @@ */ function extract_exif_data() { + global $global_var, $pwd, $get_vars, $exif_headers; + + $src_image = $get_vars['img']; + $exif_data = @exif_read_data($pwd.'/'.$src_image,0,true); + + if($exif_data) { + + foreach($exif_data as $exif_section_key => $exif_section) { + foreach($exif_section as $exif_key => $exif_value) { + + if(array_search($exif_key, $global_var['exif'])) { + + switch($exif_key) { + case 'Make': + array_push($exif_headers, 'Model: '.$exif_value); + break; + + case 'ApertureFNumber': + array_push($exif_headers, 'Aperture: '. $exif_value); + break; + + case 'FocalLength': + array_push($exif_headers, 'Focal Length: '. $exif_value .'mm'); + break; + + case 'DateTime': + array_push($exif_headers, 'Date: '.$exif_value); + break; + + case 'FlashMode': + switch($exif_value) { + case '0': + array_push($exif_headers, 'Flash: Off'); + break; + case '1': + array_push($exif_headers, 'Flash: On'); + break; + } + break; + + default: + break; + } + } + } + } + if(sizeof($exif_headers)>0) { + ksort($exif_headers); + reset($exif_headers); + } + } } @@ -151,7 +212,7 @@ function show_image() { - global $global_var, $get_vars, $pwd; + global $global_var, $get_vars, $pwd, $exif_headers; $image = $pwd.'/'.$get_vars['img']; @@ -172,12 +233,41 @@ } $image_size = GetImageSize($cached_image); + + extract_exif_data(); + + if(sizeof($exif_headers) > 0) { + + $exif_str .= sprintf("EXIF "); + + foreach($exif_headers as $exif_tag) { + $exif_str .= sprintf("| %s ", $exif_tag); + } + + echo <<\n + $exif_str\n + \n +EOT; + } + + echo <<\n \n EOT; + + $image_index = get_image_index(); + $next = get_next_image($image_index); + $prev = get_prev_image($image_index); + + echo <<prev + next +EOT; + } } @@ -206,6 +296,39 @@ } + + +function get_image_index() +{ + global $get_vars, $image_files; + + return array_search($get_vars['img'], $image_files); +} + +function get_next_image($pos) +{ + global $get_vars, $image_files; + + $next = $pos + 1; + + if($next >= sizeof($image_files)) + $next = 0; + + return $image_files[$next]; +} + +function get_prev_image($pos) +{ + global $get_vars, $image_files; + + $prev = $pos - 1; + + if($prev < 0) + $prev = sizeof($image_files) - 1; + + return $image_files[$prev]; +} + /** * Retirieves all filenames that are images exclude all * other files. It's not recursive so it only examins the @@ -330,7 +453,10 @@ - +\n
\n EOF; } @@ -348,7 +474,7 @@ echo <<\n {$global_var[str_msg][copyright]}
- expose Cvs version: \$Revision: 1.4 $ + expose Cvs version: \$Revision: 1.5 $