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
This commit is contained in:
RushLana
2025-05-21 14:47:12 +02:00
parent ce1158f55a
commit ccca7e822e

View File

@@ -731,6 +731,12 @@ class image_ext_imagick implements imageInterface
$exec = $this->imagickdir.pwg_image::get_ext_imagick_command(); $exec = $this->imagickdir.pwg_image::get_ext_imagick_command();
$exec .= ' "'.realpath($this->source_filepath).'"'; $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) foreach ($this->commands as $command => $params)
{ {
$exec .= ' -'.$command; $exec .= ' -'.$command;
@@ -739,7 +745,6 @@ class image_ext_imagick implements imageInterface
$exec .= ' '.$params; $exec .= ' '.$params;
} }
} }
$dest = pathinfo($destination_filepath); $dest = pathinfo($destination_filepath);
$exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'" 2>&1'; $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'" 2>&1';
$logger->debug($exec, 'i.php'); $logger->debug($exec, 'i.php');