# HG changeset patch # User Dan Fuhry # Date 1335333715 14400 # Node ID 570abc94bd7f34c6dae296194c4be0e577dac96a # Parent 53c7e3cc7fb577064f37b5d402f8d334bc911140 Image scaling: Fixed a bug where (height > width) images would be scaled to the wrong dimensions (GD). Added PNG/GIF transparency support to GD image resizer. Added a cache bypass option to SpecialUpDownload. diff -r 53c7e3cc7fb5 -r 570abc94bd7f includes/functions.php --- a/includes/functions.php Mon Jan 16 09:23:20 2012 -0500 +++ b/includes/functions.php Wed Apr 25 02:01:55 2012 -0400 @@ -4268,6 +4268,7 @@ { die('SECURITY: ImageMagick path is screwy'); } + $magick_path = escapeshellcmd($magick_path); $cmdline = "$magick_path $in_file_sh -resize \"{$width}x{$height}>\" $out_file_sh"; system($cmdline, $return); if ( !file_exists($out_file) ) @@ -4291,7 +4292,7 @@ else if ( $ratio < 1 ) { // orig. height is greater than width - $new_width = round( $height / $ratio ); + $new_width = round( $height * $ratio ); $new_height = $height; } else if ( $ratio == 1 ) @@ -4313,6 +4314,13 @@ if ( !$oldimage ) throw new Exception('GD: Request to load input image file failed.'); + if ( $file_ext == 'png' || $file_ext == 'gif' ) + { + imagecolortransparent($newimage, imagecolorallocatealpha($newimage, 0, 0, 0, 127)); + imagealphablending($newimage, false); + imagesavealpha($newimage, true); + } + // Perform scaling imagecopyresampled($newimage, $oldimage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig); diff -r 53c7e3cc7fb5 -r 570abc94bd7f plugins/SpecialUpdownload.php --- a/plugins/SpecialUpdownload.php Mon Jan 16 09:23:20 2012 -0500 +++ b/plugins/SpecialUpdownload.php Wed Apr 25 02:01:55 2012 -0400 @@ -250,7 +250,7 @@ $extension = ".{$_GET['fmt']}"; $cache_filename = ENANO_ROOT . "/cache/{$filename}-{$row['time_id']}-{$width}x{$height}$extension"; - if ( file_exists($cache_filename) ) + if ( file_exists($cache_filename) && !isset($_GET['cache_override']) ) { $fname = $cache_filename; } @@ -281,7 +281,7 @@ } if ( $allow_scale ) { - $result = scale_image($orig_fname, $fname, $width, $height); + $result = scale_image($orig_fname, $fname, $width, $height, isset($_GET['cache_override'])); if ( !$result ) $fname = $orig_fname; }