From 1e4afd57cfbade1a678d750824aa89fa7ea48c91 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Wed, 10 Jan 2024 15:08:16 +0100 Subject: [PATCH 1/2] Fix decoding error with Imagick driver See: https://github.com/Intervention/image/issues/1261 --- src/Drivers/Imagick/Decoders/BinaryImageDecoder.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Drivers/Imagick/Decoders/BinaryImageDecoder.php b/src/Drivers/Imagick/Decoders/BinaryImageDecoder.php index e5db1418..ac001ef7 100644 --- a/src/Drivers/Imagick/Decoders/BinaryImageDecoder.php +++ b/src/Drivers/Imagick/Decoders/BinaryImageDecoder.php @@ -29,7 +29,12 @@ public function decode(mixed $input): ImageInterface|ColorInterface throw new DecoderException('Unable to decode input'); } - $imagick = $imagick->coalesceImages(); + // For some JPEG formats, the "coalesceImages()" call leads to an image + // completely filled with background color. The logic behind this is + // incomprehensible; could be an imagemagick bug. + if ($imagick->getImageFormat() != 'JPEG') { + $imagick = $imagick->coalesceImages(); + } // fix image orientation switch ($imagick->getImageOrientation()) { From f3cef584c077dc65daf934d08b9d010c374905b6 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Fri, 12 Jan 2024 09:13:33 +0100 Subject: [PATCH 2/2] Change bugfix description comment --- src/Drivers/Imagick/Decoders/BinaryImageDecoder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Drivers/Imagick/Decoders/BinaryImageDecoder.php b/src/Drivers/Imagick/Decoders/BinaryImageDecoder.php index ac001ef7..0044ee47 100644 --- a/src/Drivers/Imagick/Decoders/BinaryImageDecoder.php +++ b/src/Drivers/Imagick/Decoders/BinaryImageDecoder.php @@ -31,7 +31,7 @@ public function decode(mixed $input): ImageInterface|ColorInterface // For some JPEG formats, the "coalesceImages()" call leads to an image // completely filled with background color. The logic behind this is - // incomprehensible; could be an imagemagick bug. + // incomprehensible for me; could be an imagick bug. if ($imagick->getImageFormat() != 'JPEG') { $imagick = $imagick->coalesceImages(); }