From 0799fd01f305c95adb3b531f80bee709b0b3eb8f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 12 Dec 2020 18:41:36 +0100 Subject: [PATCH] Greatly improve the performance of GIF processing with ImageMagick --- .../system/image/adapter/ImagickImageAdapter.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php b/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php index 38754775df..e690e2a618 100644 --- a/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php +++ b/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php @@ -356,6 +356,16 @@ class ImagickImageAdapter implements IImageAdapter { fclose($file); } else { + // Greatly reduces the time required to create the image and drastically + // reduces the filesize to more reasonable levels without a visible + // quality loss. + // + // See https://github.com/Imagick/imagick/issues/360 + if ($image->getImageFormat() == 'GIF') { + $image = $image->deconstructImages(); + $image->quantizeImages(256, \Imagick::COLORSPACE_SRGB, 0, false, false); + } + $image->writeImages($filename, true); } } -- 2.20.1