Skip to content

Commit

Permalink
Allow animated WEBP's (#1375)
Browse files Browse the repository at this point in the history
* Don't merge layers when image is animated
* Update src/Drivers/Imagick/Encoders/WebpEncoder.php

---------

Co-authored-by: Oliver Vogel <[email protected]>
  • Loading branch information
phknot and olivervogel authored Jul 5, 2024
1 parent 115d2ad commit 5451ff9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Drivers/Imagick/Encoders/WebpEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5451ff9

Please sign in to comment.