--- expose/index.php 2003/11/05 14:21:33 1.3 +++ expose/index.php 2003/11/05 15:40:21 1.4 @@ -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.3 2003/11/05 14:21:33 cam Exp $ +$Id: index.php,v 1.4 2003/11/05 15:40:21 cam Exp $ */ $global_var['metadata']['author'] = "Carl Johan Schedvin "; @@ -41,7 +41,6 @@ 'ql' => 70, 'wm' => '' ); - $global_var['image_sz']['640'] = array ( 'x' => 640, 'y' => 480, @@ -61,7 +60,7 @@ 'wm' => '' ); - +$global_var['image_sz']['default'] =& $global_var['image_sz']['640']; if(isset($_SERVER['PHP_SELF'])) { $php_self = $_SERVER['PHP_SELF']; @@ -117,20 +116,34 @@ if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir'])) mkdir($pwd.'/'.$global_var['path']['thumb_dir'],0777); + echo <<\n + +EOT; + foreach($image_files as $image) { + $thumb_image = $pwd.'/'.$global_var['path']['thumb_dir'].'/'.$image; + // check if a thumbnail for current image exists, if not create one. - if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir'].'/'.$image)) + if(!file_exists($thumb_image)) create_thumbnail($image); + $thumb_sz = GetImageSize($thumb_image); + echo <<\n - - - - \n +
\n + + + +
\n EOT; } + + echo <<\n +

\n +EOT; } @@ -140,10 +153,29 @@ { global $global_var, $get_vars, $pwd; - if(file_exists($pwd.'/'.$get_vars['img'])) { + $image = $pwd.'/'.$get_vars['img']; + + $cached_image = $pwd.'/'.$global_var['path']['cache_dir']; + + if(file_exists($image)) { + + $image_size = GetImageSize($image); + + if(isset($get_var['width'])) { + if($get_var['width'] >= $image_size[0]) + $cache_image = $image; + } 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); + echo <<\n - +
\n +
\n EOT; } @@ -152,8 +184,25 @@ -function resize_image() +function resize_image($prefix) { + global $global_var, $get_vars, $pwd; + $src_image = $get_vars['img']; + 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); + + // DEBUG: print "Quality: ".$global_var['image_sz']['default']['ql'] ." Resize Aspect: ". $resize_aspect ."%"; + + exec($global_var['external']['magick'] + .' -geometry '.$resize_aspect.'%' + .' -quality '.$global_var['image_sz']['default']['ql'] + .' '.$pwd.'/'.$src_image + .' '.$pwd.'/'.$global_var['path']['cache_dir'].'/'.$prefix.$src_image + ); + } + } } @@ -183,6 +232,7 @@ + /** * Retrieves all directory names present in $path. Using * eregi we exclude names we don't want in the list. @@ -206,6 +256,7 @@ + if (isset($get_vars['dir']) && is_dir(rawurldecode($get_vars['dir']))) { $pwd = rawurldecode($get_vars['dir']); @@ -268,7 +319,7 @@ - + expose: