|
@ -320,19 +320,23 @@ class ImageConvert extends ImageBase { |
|
|
|
|
|
|
|
|
if ($this->format == 'gif' && ($config['thumb_ext'] == 'gif' || $config['thumb_ext'] == '') && $config['thumb_keep_animation_frames'] > 1) { |
|
|
if ($this->format == 'gif' && ($config['thumb_ext'] == 'gif' || $config['thumb_ext'] == '') && $config['thumb_keep_animation_frames'] > 1) { |
|
|
if ($this->gifsicle) { |
|
|
if ($this->gifsicle) { |
|
|
if (trim($error = shell_exec("gifsicle --unoptimize -O2 --resize {$this->width}x{$this->height} < " . |
|
|
if (($error = shell_exec_error("gifsicle --unoptimize -O2 --resize {$this->width}x{$this->height} < " . |
|
|
escapeshellarg($this->src . '') . " \"#0-{$config['thumb_keep_animation_frames']}\" > " . |
|
|
escapeshellarg($this->src . '') . " \"#0-{$config['thumb_keep_animation_frames']}\" > " . |
|
|
escapeshellarg($this->temp) . '2>&1 &&echo $?') !== '0') || !file_exists($this->temp)) |
|
|
escapeshellarg($this->temp))) || !file_exists($this->temp)) |
|
|
error('Failed to resize image!', null, $error); |
|
|
error('Failed to resize image!', null, $error); |
|
|
} else { |
|
|
} else { |
|
|
if ($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' . |
|
|
if ($config['convert_manual_orient']) |
|
|
sprintf($config['convert_args'], |
|
|
$convert_args = str_replace('-auto-orient', ImageConvert::jpeg_exif_orientation($this->src), $config['convert_args']); |
|
|
|
|
|
else |
|
|
|
|
|
$convert_args = &$config['convert_args']; |
|
|
|
|
|
if (($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' . |
|
|
|
|
|
sprintf($convert_args, |
|
|
$this->width, |
|
|
$this->width, |
|
|
$this->height, |
|
|
$this->height, |
|
|
escapeshellarg($this->src), |
|
|
escapeshellarg($this->src), |
|
|
$this->width, |
|
|
$this->width, |
|
|
$this->height, |
|
|
$this->height, |
|
|
escapeshellarg($this->temp))) || !file_exists($this->temp)) |
|
|
escapeshellarg($this->temp)))) || !file_exists($this->temp)) |
|
|
error('Failed to resize image!', null, $error); |
|
|
error('Failed to resize image!', null, $error); |
|
|
if ($size = $this->get_size($this->temp)) { |
|
|
if ($size = $this->get_size($this->temp)) { |
|
|
$this->width = $size[0]; |
|
|
$this->width = $size[0]; |
|
@ -340,14 +344,18 @@ class ImageConvert extends ImageBase { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
if ($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' . |
|
|
if ($config['convert_manual_orient']) |
|
|
sprintf($config['convert_args'], |
|
|
$convert_args = str_replace('-auto-orient', ImageConvert::jpeg_exif_orientation($this->src), $config['convert_args']); |
|
|
|
|
|
else |
|
|
|
|
|
$convert_args = &$config['convert_args']; |
|
|
|
|
|
if (($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' . |
|
|
|
|
|
sprintf($convert_args, |
|
|
$this->width, |
|
|
$this->width, |
|
|
$this->height, |
|
|
$this->height, |
|
|
escapeshellarg($this->src . '[0]'), |
|
|
escapeshellarg($this->src . '[0]'), |
|
|
$this->width, |
|
|
$this->width, |
|
|
$this->height, |
|
|
$this->height, |
|
|
escapeshellarg($this->temp))) || !file_exists($this->temp)) |
|
|
escapeshellarg($this->temp)))) || !file_exists($this->temp)) |
|
|
error('Failed to resize image!', null, $error); |
|
|
error('Failed to resize image!', null, $error); |
|
|
if ($size = $this->get_size($this->temp)) { |
|
|
if ($size = $this->get_size($this->temp)) { |
|
|
$this->width = $size[0]; |
|
|
$this->width = $size[0]; |
|
@ -355,6 +363,69 @@ class ImageConvert extends ImageBase { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// For when -auto-orient doesn't exist (older versions) |
|
|
|
|
|
static public function jpeg_exif_orientation($src, $exif = false) { |
|
|
|
|
|
if (!$exif) { |
|
|
|
|
|
$exif = exif_read_data($src); |
|
|
|
|
|
if (!isset($exif['Orientation'])) |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
switch($exif['Orientation']) { |
|
|
|
|
|
case 1: |
|
|
|
|
|
// Normal |
|
|
|
|
|
return false; |
|
|
|
|
|
case 2: |
|
|
|
|
|
// 888888 |
|
|
|
|
|
// 88 |
|
|
|
|
|
// 8888 |
|
|
|
|
|
// 88 |
|
|
|
|
|
// 88 |
|
|
|
|
|
|
|
|
|
|
|
return '-flop'; |
|
|
|
|
|
case 3: |
|
|
|
|
|
|
|
|
|
|
|
// 88 |
|
|
|
|
|
// 88 |
|
|
|
|
|
// 8888 |
|
|
|
|
|
// 88 |
|
|
|
|
|
// 888888 |
|
|
|
|
|
|
|
|
|
|
|
return '-flip -flop'; |
|
|
|
|
|
case 4: |
|
|
|
|
|
// 88 |
|
|
|
|
|
// 88 |
|
|
|
|
|
// 8888 |
|
|
|
|
|
// 88 |
|
|
|
|
|
// 888888 |
|
|
|
|
|
|
|
|
|
|
|
return '-flip'; |
|
|
|
|
|
case 5: |
|
|
|
|
|
// 8888888888 |
|
|
|
|
|
// 88 88 |
|
|
|
|
|
// 88 |
|
|
|
|
|
|
|
|
|
|
|
return '-rotate 90 -flop'; |
|
|
|
|
|
case 6: |
|
|
|
|
|
// 88 |
|
|
|
|
|
// 88 88 |
|
|
|
|
|
// 8888888888 |
|
|
|
|
|
|
|
|
|
|
|
return '-rotate 90'; |
|
|
|
|
|
case 7: |
|
|
|
|
|
// 88 |
|
|
|
|
|
// 88 88 |
|
|
|
|
|
// 8888888888 |
|
|
|
|
|
|
|
|
|
|
|
return '-rotate "-90" -flop'; |
|
|
|
|
|
case 8: |
|
|
|
|
|
// 8888888888 |
|
|
|
|
|
// 88 88 |
|
|
|
|
|
// 88 |
|
|
|
|
|
|
|
|
|
|
|
return '-rotate "-90"'; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class ImagePNG extends ImageBase { |
|
|
class ImagePNG extends ImageBase { |
|
|