includes/functions.php
changeset 1373 851b91febb85
parent 1370 24f5610ea589
parent 1360 570abc94bd7f
child 1379 5cbd678df965
--- a/includes/functions.php	Mon Nov 19 11:39:25 2012 -0500
+++ b/includes/functions.php	Mon Nov 19 11:40:35 2012 -0500
@@ -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);
 		
@@ -4870,7 +4878,7 @@
 	if ( function_exists('json_decode') )
 	{
 		// using PHP5 with JSON support
-		return json_decode($data);
+		return json_decode($data, true);
 	}
 	*/