--- expose/index.php 2003/11/06 11:47:12 1.5 +++ expose/index.php 2003/11/07 22:39:24 1.8 @@ -20,7 +20,18 @@ | Version 2 along with this program; if not, visit GNU's Home Page | http://www.gnu.org/ +----------------------------------------------------------------------+ -$Id: index.php,v 1.5 2003/11/06 11:47:12 cam Exp $ +$Id: index.php,v 1.8 2003/11/07 22:39:24 cam Exp $ + + + +// CODE FOR EMBEDDING AVI/MPEG/MOV FILES IN HTML + + + + <a href="filename">click to view</a> + <img dynsrc="filename" start="mouseover" align="left" controls width="320" height="240" hspace="25"> + </a> + */ $global_var['metadata']['author'] = "Carl Johan Schedvin "; @@ -60,15 +71,14 @@ 'wm' => '' ); +$global_var['image_sz']['valid_sizes'] = array ( + '640x480', + '800x600', + '1024x768' + ); + $global_var['image_sz']['default'] =& $global_var['image_sz']['640']; -$global_var['exif'] = array ( - 'Make', - 'ApertureFNumber', - 'FocalLength', - 'DateTime', - 'FlashMode' - ); $exif_headers = array (); @@ -87,8 +97,6 @@ /** - * ! NOT IMPLEMENTED ! - * * Extracts the EXIF header of a JPG if available using * built-in php function exif_read_data, this information * is extracted upon request and not written to disk. @@ -104,11 +112,9 @@ 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': + case 'Model': array_push($exif_headers, 'Model: '.$exif_value); break; @@ -117,7 +123,10 @@ break; case 'FocalLength': - array_push($exif_headers, 'Focal Length: '. $exif_value .'mm'); + $factor = 6.49122807; + $vars = split("/",$exif_value); + $focal_length = round(($vars[0]/$vars[1])*$factor); + array_push($exif_headers, 'Focal Length: '. $focal_length .'mm'); break; case 'DateTime': @@ -134,11 +143,12 @@ break; } break; - + case 'ISOSpeedRatings'; + array_push($exif_headers, 'ISO: '.$exif_value); + break; default: break; } - } } } if(sizeof($exif_headers)>0) { @@ -221,15 +231,32 @@ if(file_exists($image)) { $image_size = GetImageSize($image); + $src_image_size = $image_size; - if(isset($get_var['width'])) { - if($get_var['width'] >= $image_size[0]) + if(isset($get_vars['width'])) { + + $cache_size = split("x",$get_vars['width']); + + if($cache_size[0] >= $src_image_size[0]) { $cache_image = $image; + } else { + if(array_search($get_vars['width'], $global_var['image_sz']['valid_sizes'])) { + if(!file_exists($pwd.'/.cache/'.$get_vars['width'].'_'.$get_vars['img'])) { + resize_image($get_vars['width'].'_'); + } + $cached_image = $pwd.'/.cache/'.$get_vars['width'].'_'.$get_vars['img']; + } + if($cache_size[0] == $global_var['image_sz']['default']['x']) + $cached_image = $cached_image.'/default_'.$get_vars['img']; + } + } else { if(!file_exists($cached_image.'/default_'.$get_vars['img'])) { resize_image('default_'); + } $cached_image = $cached_image.'/default_'.$get_vars['img']; + } $image_size = GetImageSize($cached_image); @@ -238,7 +265,7 @@ if(sizeof($exif_headers) > 0) { - $exif_str .= sprintf("EXIF "); + $exif_str .= sprintf("EXIF "); foreach($exif_headers as $exif_tag) { $exif_str .= sprintf("| %s ", $exif_tag); @@ -262,10 +289,34 @@ $image_index = get_image_index(); $next = get_next_image($image_index); $prev = get_prev_image($image_index); + + echo <<Size:  +EOT; + foreach($global_var['image_sz']['valid_sizes'] as $new_size) { + + if($get_vars['width'] == $new_size) { + echo $new_size; + } elseif($cache_size[0] >= $src_image_size[0]) { + } else { + + echo <<$new_size  +EOT; + } + + } + echo <<prev - next + {$src_image_size[0]}x{$src_image_size[1]} +EOT; + + echo <<\n + prev + next\n + \n EOT; } @@ -278,19 +329,35 @@ { global $global_var, $get_vars, $pwd; $src_image = $get_vars['img']; + $cache_dir = $pwd.'/'.$global_var['path']['cache_dir']; + if(isset($global_var['external']['magick'])) { if(file_exists($pwd.'/'.$src_image)) { + $src_image_sz = GetImageSize($pwd.'/'.$src_image); $resize_aspect = round(($global_var['image_sz']['default']['y'] / $src_image_sz[1])*100, 2); + $resize_quality = $global_var['image_sz']['default']['ql']; + + if(isset($get_vars['width'])) { + $new_width = split("x", $get_vars['width']); + $resize_aspect = round(($new_width[1] / $src_image_sz[1])*100, 2); + } // DEBUG: print "Quality: ".$global_var['image_sz']['default']['ql'] ." Resize Aspect: ". $resize_aspect ."%"; + if(!file_exists($cache_dir)) + mkdir($cache_dir,0777); + + $debug = array(); + exec($global_var['external']['magick'] .' -geometry '.$resize_aspect.'%' - .' -quality '.$global_var['image_sz']['default']['ql'] + .' -quality '.$resize_quality .' '.$pwd.'/'.$src_image - .' '.$pwd.'/'.$global_var['path']['cache_dir'].'/'.$prefix.$src_image + .' '.$pwd.'/'.$global_var['path']['cache_dir'].'/'.$prefix.$src_image, $debug, $ret_val ); + + print_r($debug); } } } @@ -329,6 +396,15 @@ return $image_files[$prev]; } + +function get_split_path() +{ + global $pwd; + + $split_path = split('/', $pwd); + + return $split_path; +} /** * Retirieves all filenames that are images exclude all * other files. It's not recursive so it only examins the @@ -346,7 +422,7 @@ $pwd_dd = opendir($path); while(($file = readdir($pwd_dd)) !== false) { if(is_file($path."/".$file) - && !eregi("^\.|^.*.php|^.*.css|^.*~",$file)) + && !eregi("^\.|^.*.php|^.*.css|^.*~|^.txt",$file)) array_push($images, $file); } } @@ -380,6 +456,37 @@ + + +function create_directory_browser() +{ + global $pwd, $dir_files; + + if(sizeof($dir_files)>0) { + + foreach($dir_files as $dir) { + + $dir_image = 'open.png'; + + if(file_exists($pwd.'/'.$dir.'/.htaccess')) + $dir_image = 'protected.png'; + + echo <<\n + \n +
$dir\n +
\n + \n +EOT; + } + } +} + + + + + + if (isset($get_vars['dir']) && is_dir(rawurldecode($get_vars['dir']))) { $pwd = rawurldecode($get_vars['dir']); @@ -394,9 +501,12 @@ // print the html header before continuing processing. html_template_header(); +//if($global_var['navigation_bar']) + html_template_navbar(); if(sizeof($image_files) <= 0) { if(sizeof($dir_files) > 0) { + create_directory_browser(); } else { } } else { @@ -409,6 +519,9 @@ } } + + + // print the html footer to make it nice and tidy. html_template_footer(); @@ -445,7 +558,7 @@ expose: @@ -464,6 +577,9 @@ + + + /** * Prints the html footer, this contains only closing * tags for the html document and the copyright notice. @@ -473,12 +589,47 @@ global $global_var; echo <<\n - {$global_var[str_msg][copyright]}
- expose Cvs version: \$Revision: 1.5 $ - - - - + {$global_var[str_msg][copyright]}
\n + \$Revision: 1.8 $\n + \n\n +\n +\n +\n EOF; } + + + + + + +function html_template_navbar() +{ + global $get_vars; + $split_path = get_split_path(); + + if(sizeof($split_path) > 0) { + + foreach($split_path as $dir) { + if($dir!='') { + $path .= $dir.'/'; + echo << +EOT; + if($dir == '.') + $dir = 'expose'; + + echo << > \n +EOT; + } + } + if(isset($get_vars['img'])) { + echo <<