From 4851d4cabeebdd72764e75fe8d51f45c0e436c32 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 03:51:50 -0400 Subject: Forgot "global $config" here --- inc/image.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/image.php') diff --git a/inc/image.php b/inc/image.php index 99c10252..c39d7694 100644 --- a/inc/image.php +++ b/inc/image.php @@ -173,6 +173,7 @@ class ImageImagick extends ImageBase { } } public function to($src) { + global $config; if ($config['strip_exif']) { $this->image->stripImage(); } -- cgit v1.3 From 22f3a95e0e421de05a11633eac846df96a2a4768 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 04:24:34 -0400 Subject: convert+gifscale didn't respect $config['thumb_keep_animation_frames'] --- inc/config.php | 7 +++---- inc/image.php | 5 ++++- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'inc/image.php') diff --git a/inc/config.php b/inc/config.php index 75384d3f..cec996c1 100644 --- a/inc/config.php +++ b/inc/config.php @@ -412,9 +412,9 @@ // Thumbnail extension, empty for inherited (png recommended) $config['thumb_ext'] = 'png'; - // EXPERIMENTAL: // Maximum amount of frames to resize (more frames means more processing power). "1" means no animated thumbnails. - // Requires $config['thumb_ext'] to be 'gif' $config['imagick'] to be enabled. + // Requires $config['thumb_ext'] to be 'gif' and $config['thumb_method'] to be 'imagick', 'convert', or 'convert+gifsicle'. + // Not respected by 'convert'; will just resize all frames if this is > 1. $config['thumb_keep_animation_frames'] = 1; // Thumbnailing method: @@ -426,8 +426,7 @@ // PHP Imagick. // - 'convert+gifsicle' Same as above, with the exception of using `gifsicle` (command line application) // instead of `convert` for resizing gifs. It's faster and resulting animated gifs - // have less artifacts than if resized with ImageMagick. - + // have less artifacts than if resized with ImageMagick. $config['thumb_method'] = 'gd'; // Strip EXIF metadata from JPEG files diff --git a/inc/image.php b/inc/image.php index c39d7694..5910cb85 100644 --- a/inc/image.php +++ b/inc/image.php @@ -282,10 +282,13 @@ class ImageConvert extends ImageBase { $quality = $config['thumb_quality'] * 10; + $config['thumb_keep_animation_frames'] = (int) $config['thumb_keep_animation_frames']; + if ($this->format == 'gif' && ($config['thumb_ext'] == 'gif' || $config['thumb_ext'] == '') && $config['thumb_keep_animation_frames'] > 1) { if ($this->gifsicle) { if (shell_exec("gifsicle --unoptimize -O2 --resize {$this->width}x{$this->height} < " . - escapeshellarg($this->src . '') . " > " . escapeshellarg($this->temp)) || !file_exists($this->temp)) + escapeshellarg($this->src . '') . " \"#0-{$config['thumb_keep_animation_frames']}\" > " . + escapeshellarg($this->temp)) || !file_exists($this->temp)) error('Failed to resize image!'); } else { if (shell_exec("convert -background transparent -filter Point -sample {$this->width}x{$this->height} +antialias -quality {$quality} " . -- cgit v1.3 From 40ab2e0c1728fab613bc16a19ab8fcb3fa78c1d4 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 21:28:16 -0400 Subject: Don't redraw image again after correcting image orientation; Correct image orientation with convert+gifsicle too --- inc/image.php | 4 ++-- post.php | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'inc/image.php') diff --git a/inc/image.php b/inc/image.php index 5910cb85..51db2f83 100644 --- a/inc/image.php +++ b/inc/image.php @@ -251,9 +251,9 @@ class ImageConvert extends ImageBase { if (!$this->temp) { if ($config['strip_exif']) { - shell_exec('convert ' . escapeshellarg($this->src) . ' -strip ' . escapeshellarg($src)); + shell_exec('convert ' . escapeshellarg($this->src) . ' -auto-orient -strip ' . escapeshellarg($src)); } else { - shell_exec('convert ' . escapeshellarg($this->src) . ' ' . escapeshellarg($src)); + shell_exec('convert ' . escapeshellarg($this->src) . ' -auto-orient ' . escapeshellarg($src)); } } else { rename($this->temp, $src); diff --git a/post.php b/post.php index 22782ca7..5031830f 100644 --- a/post.php +++ b/post.php @@ -450,10 +450,12 @@ if (isset($_POST['delete'])) { if ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg') { // The following code corrects the image orientation. // Currently only works with the 'convert' option selected but it could easily be expanded to work with the rest if you can be bothered. - if ($config['thumb_method'] == 'convert') { - $exif = exif_read_data($upload); - if (isset($exif['Orientation']) && $exif['Orientation'] != 1) { - shell_exec('convert ' . escapeshellarg($upload) . ' -auto-orient ' . escapeshellarg($upload)); + if (!($config['redraw_image'] || ($config['strip_exif'] && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg')))) { + if ($config['thumb_method'] == 'convert' || $config['thumb_method'] == 'convert+gifsicle') { + $exif = exif_read_data($upload); + if (isset($exif['Orientation']) && $exif['Orientation'] != 1) { + shell_exec('convert ' . escapeshellarg($upload) . ' -auto-orient ' . escapeshellarg($upload)); + } } } } -- cgit v1.3