From ccca7e822e300c1f1446631144183d2c44c05ff3 Mon Sep 17 00:00:00 2001 From: RushLana Date: Wed, 21 May 2025 14:47:12 +0200 Subject: [PATCH] Fix webp animation derivatives Using imagick to generate derivates on an animated webp break animation Applying "-layers coalesce" ensure the animation remain smooth Refs : - https://github.com/ImageMagick/ImageMagick/issues/6375 - https://github.com/ImageMagick/ImageMagick/issues/5542 - https://github.com/ImageMagick/ImageMagick/issues/4246 --- admin/include/image.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/admin/include/image.class.php b/admin/include/image.class.php index ace71bc3b..2b1119e3f 100644 --- a/admin/include/image.class.php +++ b/admin/include/image.class.php @@ -731,6 +731,12 @@ class image_ext_imagick implements imageInterface $exec = $this->imagickdir.pwg_image::get_ext_imagick_command(); $exec .= ' "'.realpath($this->source_filepath).'"'; + // If the image is animated webp add a filter to avoid breaking the animation + if ($this->is_animated_webp) + { + $exec .= ' -layers coalesce '; + } + foreach ($this->commands as $command => $params) { $exec .= ' -'.$command; @@ -739,7 +745,6 @@ class image_ext_imagick implements imageInterface $exec .= ' '.$params; } } - $dest = pathinfo($destination_filepath); $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'" 2>&1'; $logger->debug($exec, 'i.php');