1
0

fixed magick images

This commit is contained in:
www-data 2018-02-04 00:00:35 +01:00
parent ca07729318
commit e2a4b519b5
2 changed files with 11 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -296,7 +296,16 @@ function smart_resize_image($file, $width = 0, $height = 0, $proportional, $outp
*/ */
function magick_resize_image($file, $width, $height, $output) function magick_resize_image($file, $width, $height, $output)
{ {
$cmd = 'convert "' . $file . '" -strip -resize ' . $width . 'x' . $height . ' "' . $output . '"'; list($width_old, $height_old) = getimagesize($file);
if ($width == 0) $factor = $height/$height_old;
elseif ($height == 0) $factor = $width/$width_old;
else $factor = min( $width / $width_old, $height / $height_old );
$final_width = round( $width_old * $factor );
$final_height = round( $height_old * $factor );
$cmd = 'convert "' . $file . '" -strip -resize ' . $final_width . 'x' . $final_height . ' "' . $output . '"';
shell_exec($cmd); shell_exec($cmd);
} }
@ -354,4 +363,4 @@ function get_client_ip() {
else if(isset($_SERVER['HTTP_FORWARDED'])) return $_SERVER['HTTP_FORWARDED']; else if(isset($_SERVER['HTTP_FORWARDED'])) return $_SERVER['HTTP_FORWARDED'];
else if(isset($_SERVER['REMOTE_ADDR'])) return $_SERVER['REMOTE_ADDR']; else if(isset($_SERVER['REMOTE_ADDR'])) return $_SERVER['REMOTE_ADDR'];
else return 'UNKNOWN'; else return 'UNKNOWN';
} }