From 5451ff9f909c2fc836722e5ed6831b9f9a6db68c Mon Sep 17 00:00:00 2001 From: "P.H. Knot" <36478829+phknot@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:35:01 +0200 Subject: [PATCH] Allow animated WEBP's (#1375) * Don't merge layers when image is animated * Update src/Drivers/Imagick/Encoders/WebpEncoder.php --------- Co-authored-by: Oliver Vogel --- src/Drivers/Imagick/Encoders/WebpEncoder.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Drivers/Imagick/Encoders/WebpEncoder.php b/src/Drivers/Imagick/Encoders/WebpEncoder.php index 552b23ab..93a26fd9 100644 --- a/src/Drivers/Imagick/Encoders/WebpEncoder.php +++ b/src/Drivers/Imagick/Encoders/WebpEncoder.php @@ -21,7 +21,10 @@ public function encode(ImageInterface $image): EncodedImage $imagick = $image->core()->native(); $imagick->setImageBackgroundColor(new ImagickPixel('transparent')); - $imagick = $imagick->mergeImageLayers(Imagick::LAYERMETHOD_MERGE); + if (!$image->isAnimated()) { + $imagick = $imagick->mergeImageLayers(Imagick::LAYERMETHOD_MERGE); + } + $imagick->setFormat($format); $imagick->setImageFormat($format); $imagick->setCompression($compression);