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] 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) {