[Picfinity-commit] SF.net SVN: picfinity: [24] index.php
Status: Beta
Brought to you by:
espadav8
From: <esp...@us...> - 2007-08-09 18:24:08
|
Revision: 24 http://picfinity.svn.sourceforge.net/picfinity/?rev=24&view=rev Author: espadav8 Date: 2007-08-09 11:24:11 -0700 (Thu, 09 Aug 2007) Log Message: ----------- Change the checking order for thumbnails (check for the file first, then check/create the folder) Modified Paths: -------------- index.php Modified: index.php =================================================================== --- index.php 2007-08-09 12:44:59 UTC (rev 23) +++ index.php 2007-08-09 18:24:11 UTC (rev 24) @@ -29,9 +29,6 @@ $post_id = 0; } - // not implemented yet - $max_folders = 0; // 0 = unlimited - // create thumbnails for images that don't have one already $create_thumbnails = true; @@ -226,78 +223,78 @@ global $thumbnail_width; global $thumbnail_height; + if (file_exists('.thumbs/'.$folder.'/'.$image)) + { + // if it already exists, do nothing + return; + } if (!is_dir('.thumbs/'.$folder)) { MakeDirectory('.thumbs/'.$folder, 0777); chmod('.thumbs/'.$folder, 0777); } - if (file_exists('.thumbs/'.$folder.'/'.$image)) + + $src_img; + switch ($ext) { - // if it already exists, do nothing - return; + case 'png': + $src_img = imagecreatefrompng($folder.'/'.$image); + break; + case 'jpg': + case 'jpeg': + $src_img = imagecreatefromjpeg($folder.'/'.$image); + break; + case 'gif': + $src_img = imagecreatefromgif($folder.'/'.$image); + break; + case 'bmp': + $src_img = imagecreatefrombmp($folder.'/'.$image); + break; + default: + return; + break; } - else + + $old_x = imageSX($src_img); + $old_y = imageSY($src_img); + + if ($old_x > $old_y) { + $thumb_w = $thumbnail_width; + $thumb_h = $old_y * ($thumbnail_height/$old_x); + } + else if ($old_x < $old_y) { + $thumb_w = $old_x * ($thumbnail_width/$old_y); + $thumb_h = $thumbnail_height; + } + else if ($old_x == $old_y) { + $thumb_w = $thumbnail_width; + $thumb_h = $thumbnail_height; + } + + $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h); + imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); + + switch ($ext) { - $src_img; - switch ($ext) - { - case 'png': - $src_img = imagecreatefrompng($folder.'/'.$image); - break; - case 'jpg': - case 'jpeg': - $src_img = imagecreatefromjpeg($folder.'/'.$image); - break; - case 'gif': - $src_img = imagecreatefromgif($folder.'/'.$image); - break; - case 'bmp': - $src_img = imagecreatefrombmp($folder.'/'.$image); - break; - default: - return; - break; - } - - $old_x = imageSX($src_img); - $old_y = imageSY($src_img); - - if ($old_x > $old_y) { - $thumb_w = $thumbnail_width; - $thumb_h = $old_y * ($thumbnail_height/$old_x); - } - else if ($old_x < $old_y) { - $thumb_w = $old_x * ($thumbnail_width/$old_y); - $thumb_h = $thumbnail_height; - } - else if ($old_x == $old_y) { - $thumb_w = $thumbnail_width; - $thumb_h = $thumbnail_height; - } - - $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h); - imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); - - switch ($ext) - { - case 'png': - imagepg($dst_img, '.thumbs/'.$folder.'/'.$image); - break; - case 'jpg': - case 'jpeg': - imagejpeg($dst_img, '.thumbs/'.$folder.'/'.$image); - break; - case 'gif': - imagegif($dst_img, '.thumbs/'.$folder.'/'.$image); - break; - case 'bmp': - imagebmp($dst_img, '.thumbs/'.$folder.'/'.$image); - break; - } - - imagedestroy($dst_img); - imagedestroy($src_img); + case 'png': + imagepg($dst_img, '.thumbs/'.$folder.'/'.$image); + break; + case 'jpg': + case 'jpeg': + imagejpeg($dst_img, '.thumbs/'.$folder.'/'.$image); + break; + case 'gif': + imagegif($dst_img, '.thumbs/'.$folder.'/'.$image); + break; + case 'bmp': + imagebmp($dst_img, '.thumbs/'.$folder.'/'.$image); + break; } + + imagedestroy($dst_img); + imagedestroy($src_img); + + return; } function array_to_xml(&$array, $tag_name = 'image', $headless = false) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |