From 0eac9a2f7dfe5fefe383ac14fdd5cb5066fd1d7a Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Mon, 18 Oct 2021 18:32:11 +0200 Subject: [PATCH] Set the initial imagick colorspace whenever possible --- src/Imagick/Image.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Imagick/Image.php b/src/Imagick/Image.php index bd25e99a..17bb5f49 100644 --- a/src/Imagick/Image.php +++ b/src/Imagick/Image.php @@ -71,7 +71,7 @@ public function __construct(\Imagick $imagick, PaletteInterface $palette, Metada { $this->metadata = $metadata; $this->imagick = $imagick; - if (static::getDriverInfo()->hasFeature(DriverInfo::FEATURE_COLORSPACECONVERSION)) { + if (method_exists($imagick, 'setcolorspace')) { $this->setColorspace($palette, false); } $this->palette = $palette; @@ -998,7 +998,7 @@ private function setColorspace(PaletteInterface $palette, $convert) } } catch (\ImagickException $x) { // Old ImageMagick versions ( < 6.8.0-4) were affected by a bug, fixed in https://github.com/ImageMagick/ImageMagick6/commit/8354515c613b61bd52e025ec0f6799cbf0f1a069 - if ($x->getMessage() !== 'Unable to set image alpha channel' || version_compare(Imagine::getExtensionInfo()->getImageMagickSemVerVersion(), '6.8.0') > 0) { + if ($x->getMessage() !== 'Unable to set image alpha channel' || version_compare($this->getDriverInfo()->getEngineVersion(), '6.8.0') > 0) { throw $x; } }