From: Alexander Ebert Date: Sat, 12 Dec 2020 17:41:36 +0000 (+0100) Subject: Greatly improve the performance of GIF processing with ImageMagick X-Git-Tag: 5.3.2~42^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0799fd01f305c95adb3b531f80bee709b0b3eb8f;p=GitHub%2FWoltLab%2FWCF.git Greatly improve the performance of GIF processing with ImageMagick --- 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); } }