includes/functions.php
changeset 1360 570abc94bd7f
parent 1357 4f83d730633f
child 1373 851b91febb85
--- 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);