From a752a3930ce4b80d062c62770e769101053a9e5a Mon Sep 17 00:00:00 2001 From: discomrade <83621080+discomrade@users.noreply.github.com> Date: Wed, 23 Jun 2021 11:52:29 +0000 Subject: [PATCH 1/2] Fix custom thumb_ext for ImageMagick convert When using ImageMagick's convert tool, the output defaults to the input format if no file extension or format is specified. The temp file currently has no extension, so a $config['thumb_ext'] value has no effect on the image. By appending the thumb_ext to the temp output file, it will convert the image to the intended format. You can see this issue present on lainchan, where thumbnails have a .png filename but are not really PNG files when the input is a .jpg, for example. --- inc/image.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/image.php b/inc/image.php index c3cac504..7f26a64a 100644 --- a/inc/image.php +++ b/inc/image.php @@ -311,8 +311,8 @@ class ImageConvert extends ImageBase { $this->destroy(); } - $this->temp = tempnam($config['tmp'], 'convert'); - + $this->temp = tempnam($config['tmp'], 'convert') . ($config['thumb_ext'] == '' ? '.' . $config['thumb_ext'] : ''); + $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) { From 54cd4d41f2c3a47ac6b891aa3a72d87349d4eb76 Mon Sep 17 00:00:00 2001 From: discomrade <83621080+discomrade@users.noreply.github.com> Date: Wed, 23 Jun 2021 12:40:27 +0000 Subject: [PATCH 2/2] Fix custom thumb_ext for ImageMagick convert Fixed breaking typo in previous commit --- inc/image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/image.php b/inc/image.php index 7f26a64a..a944fad9 100644 --- a/inc/image.php +++ b/inc/image.php @@ -311,7 +311,7 @@ class ImageConvert extends ImageBase { $this->destroy(); } - $this->temp = tempnam($config['tmp'], 'convert') . ($config['thumb_ext'] == '' ? '.' . $config['thumb_ext'] : ''); + $this->temp = tempnam($config['tmp'], 'convert') . ($config['thumb_ext'] == '' ? '' : '.' . $config['thumb_ext']); $config['thumb_keep_animation_frames'] = (int)$config['thumb_keep_animation_frames'];