Common subdirectories: MiniGal Nano 0.3.5//cache and minigal//cache diff -Nau MiniGal Nano 0.3.5//config_default.php minigal//config_default.php --- MiniGal Nano 0.3.5//config_default.php 2010-11-28 23:36:00.000000000 +0100 +++ minigal//config_default.php 2011-04-15 21:35:21.654881001 +0200 @@ -37,7 +37,8 @@ $label_loading = "Loading..."; //Thumbnail loading text //ADVANCED SETTINGS +$img_size = 1024; // Image size $thumb_size = 120; //Thumbnail height/width (square thumbs). Changing this will most likely require manual altering of the template file to make it look properly! $label_max_length = 30; //Maximum chars of a folder name that will be displayed on the folder thumbnail $display_exif = 0; -?> \ No newline at end of file +?> diff -Nau MiniGal Nano 0.3.5//createthumb.php minigal//createthumb.php --- MiniGal Nano 0.3.5//createthumb.php 2010-12-06 10:45:00.000000000 +0100 +++ minigal//createthumb.php 2011-04-15 21:14:27.464881000 +0200 @@ -22,8 +22,16 @@ // error_reporting(E_ALL); if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename'])) header('Content-type: image/jpeg'); -if (preg_match("/.gif$/i", $_GET['filename'])) header('Content-type: image/gif'); -if (preg_match("/.png$/i", $_GET['filename'])) header('Content-type: image/png'); +elseif (preg_match("/.gif$/i", $_GET['filename'])) header('Content-type: image/gif'); +elseif (preg_match("/.png$/i", $_GET['filename'])) header('Content-type: image/png'); +else die("Not supported image type"); + +// Cache for 14 days +$expires = 60*60*24*14; +header("Pragma: public"); +header("Cache-Control: maxage=".$expires); +header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); +$_GET['filename'] = str_replace("/..", "", $_GET['filename']); // Display error image if file isn't found if (!is_file($_GET['filename'])) { @@ -31,30 +39,62 @@ $errorimage = ImageCreateFromJPEG('images/questionmark.jpg'); ImageJPEG($errorimage,null,90); } - + + $nocrop = ""; + if (isset($_GET['nocrop'])) + $nocrop = "-nocrop"; + + $cachefile = "cache/" . (int)$_GET['size'] . "$nocrop/" . $_GET['filename']; + if (is_file($cachefile)) { + echo file_get_contents($cachefile); + exit(); + } + elseif(is_writeable("cache/")) { + $outfile = $cachefile; + + $old = umask(0); + mkdir(dirname($cachefile), 0777, true); + umask($old); + } + else + $outfile = null; + + // Display error image if file exists, but can't be opened if (substr(decoct(fileperms($_GET['filename'])), -1, strlen(fileperms($_GET['filename']))) < 4 OR substr(decoct(fileperms($_GET['filename'])), -3,1) < 4) { header('Content-type: image/jpeg'); $errorimage = ImageCreateFromJPEG('images/cannotopen.jpg'); ImageJPEG($errorimage,null,90); } - + + // Define variables $target = ""; $xoord = 0; $yoord = 0; - if ($_GET['size'] == "") $_GET['size'] = 120; // - $imgsize = GetImageSize($_GET['filename']); - $width = $imgsize[0]; - $height = $imgsize[1]; - if ($width > $height) { // If the width is greater than the height it’s a horizontal picture - $xoord = ceil(($width-$height)/2); - $width = $height; // Then we read a square frame that equals the width - } else { - $yoord = ceil(($height-$width)/2); - $height = $width; - } + if ($_GET['size'] == "") + $_GET['size'] = 120; // + + $imgsize = GetImageSize($_GET['filename']); + $width = $imgsize[0]; + $height = $imgsize[1]; + + if (isset($_GET['nocrop'])) { + $size_w = $_GET['size']; + $size_h = (($_GET['size']/$width)*$height); + } + else { + $size_w = $size_h = $_GET['size']; + if ($width > $height) { // If the width is greater than the height it’s a horizontal picture + $xoord = ceil(($width-$height)/2); + $width = $height; // Then we read a square frame that equals the width + } else { + $yoord = ceil(($height-$width)/2); + $height = $width; + } + } + // Rotate JPG pictures if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename'])) { @@ -64,6 +104,9 @@ $degrees = 0; switch($ort) { + case 3: // rotate around + $degrees = 180; + break; case 6: // 90 rotate right $degrees = 270; break; @@ -74,19 +117,22 @@ if ($degrees != 0) $target = imagerotate($target, $degrees, 0); } } - - $target = ImageCreatetruecolor($_GET['size'],$_GET['size']); + + $target = ImageCreatetruecolor($size_w, $size_h); if (preg_match("/.jpg$/i", $_GET['filename'])) $source = ImageCreateFromJPEG($_GET['filename']); - if (preg_match("/.gif$/i", $_GET['filename'])) $source = ImageCreateFromGIF($_GET['filename']); - if (preg_match("/.png$/i", $_GET['filename'])) $source = ImageCreateFromPNG($_GET['filename']); - imagecopyresampled($target,$source,0,0,$xoord,$yoord,$_GET['size'],$_GET['size'],$width,$height); + if (preg_match("/.gif$/i", $_GET['filename'])) $source = ImageCreateFromGIF($_GET['filename']); + if (preg_match("/.png$/i", $_GET['filename'])) $source = ImageCreateFromPNG($_GET['filename']); + imagecopyresampled($target,$source,0,0,$xoord,$yoord,$size_w,$size_h,$width,$height); imagedestroy($source); - if (preg_match("/.jpg$/i", $_GET['filename'])) ImageJPEG($target,null,90); - if (preg_match("/.gif$/i", $_GET['filename'])) ImageGIF($target,null,90); - if (preg_match("/.png$/i", $_GET['filename'])) ImageJPEG($target,null,90); // Using ImageJPEG on purpose - imagedestroy($target); + if (preg_match("/.jpg$/i", $_GET['filename'])) ImageJPEG($target,$outfile,90); + if (preg_match("/.gif$/i", $_GET['filename'])) ImageGIF($target,$outfile,90); + if (preg_match("/.png$/i", $_GET['filename'])) ImageJPEG($target,$outfile,90); // Using ImageJPEG on purpose + imagedestroy($target); + + if ($outfile) + echo file_get_contents($outfile); -?> \ No newline at end of file +?> Common subdirectories: MiniGal Nano 0.3.5//css and minigal//css Common subdirectories: MiniGal Nano 0.3.5//images and minigal//images diff -Nau MiniGal Nano 0.3.5//index.php minigal//index.php --- MiniGal Nano 0.3.5//index.php 2010-12-06 10:22:00.000000000 +0100 +++ minigal//index.php 2011-04-06 15:39:17.804881000 +0200 @@ -214,7 +214,7 @@ "name" => $file, "date" => filemtime($currentdir . "/" . $file), "size" => filesize($currentdir . "/" . $file), - "html" => "