From 9deb50b0bce2ac7d65addeb67040514d517bb25b Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sun, 11 Aug 2024 13:41:19 +0200 Subject: [PATCH] Change colorspace adjustment logic --- .../Imagick/Decoders/NativeObjectDecoder.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Drivers/Imagick/Decoders/NativeObjectDecoder.php b/src/Drivers/Imagick/Decoders/NativeObjectDecoder.php index 0799b92e..48e50b4b 100644 --- a/src/Drivers/Imagick/Decoders/NativeObjectDecoder.php +++ b/src/Drivers/Imagick/Decoders/NativeObjectDecoder.php @@ -17,13 +17,6 @@ use Intervention\Image\Modifiers\RemoveAnimationModifier; class NativeObjectDecoder extends SpecializableDecoder implements SpecializedInterface { - protected const SUPPORTED_COLORSPACES = [ - Imagick::COLORSPACE_SRGB, - Imagick::COLORSPACE_CMYK, - Imagick::COLORSPACE_HSL, - Imagick::COLORSPACE_HSB, - ]; - public function decode(mixed $input): ImageInterface|ColorInterface { if (!is_object($input)) { @@ -41,10 +34,10 @@ class NativeObjectDecoder extends SpecializableDecoder implements SpecializedInt $input = $input->coalesceImages(); } - // turn image into rgb if colorspace if other than CMYK, RGB, HSL or HSV. - // this prevents working on greyscale colorspace images when loading - // from PNG color type greyscale format. - if (!in_array($input->getImageColorspace(), self::SUPPORTED_COLORSPACES)) { + // turn images with colorspace 'GRAY' into 'SRGB' to avoid working on + // greyscale colorspace images as this results images loosing color + // information when placed into this image. + if ($input->getImageColorspace() == Imagick::COLORSPACE_GRAY) { $input->setImageColorspace(Imagick::COLORSPACE_SRGB); }