From f3c1e3b2eedff1c2cafec81306751eb0a7c95628 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 2 Sep 2019 16:44:12 +0200 Subject: [PATCH] Optional override for the ImageMagick filter Closes #3057 --- .../adapter/ImagickImageAdapter.class.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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 36bb7bcd09..ca392af0b2 100644 --- a/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php +++ b/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php @@ -1,5 +1,6 @@ clip($originX, $originY, $originWidth, $originHeight); - $this->imagick->resizeImage($targetWidth, $targetHeight, \Imagick::FILTER_POINT, 0); + $this->imagick->resizeImage($targetWidth, $targetHeight, $this->getResizeFilter(), 0); } } @@ -416,6 +417,24 @@ class ImagickImageAdapter implements IImageAdapter { // does nothing } + /** + * Returns the preferred image filter used during image resizing. + * + * @return int + */ + protected function getResizeFilter() { + static $filter; + + if ($filter === null) { + $parameters = ['filter' => null]; + EventHandler::getInstance()->fireAction($this, 'getResizeFilter', $parameters); + + $filter = $parameters['filter'] ?? \Imagick::FILTER_POINT; + } + + return $filter; + } + /** * @inheritDoc */ -- 2.20.1