Skip to content

Commit

Permalink
animated gifs can not be transformed to the webp format
Browse files Browse the repository at this point in the history
We can't efficiently check if the input is an animated gif, therefore we
catch the exception and try to convert to gif if converting to webp
failed.
  • Loading branch information
Yoann-TYT authored and dbu committed Jan 11, 2022
1 parent 66f5cdf commit 977d23b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Imagine/Filter/FilterManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,17 @@ private function exportConfiguredImageBinary(BinaryInterface $binary, ImageInter
}

$filteredFormat = $config['format'] ?? $binary->getFormat();
$filteredString = $image->get($filteredFormat, $options);
try {
$filteredString = $image->get($filteredFormat, $options);
} catch (\Exception $exception) {
// we don't support converting an animated gif into webp.
// we can't efficiently check the input data, therefore we retry with target format gif in case of an error.
if ('webp' !== $filteredFormat || !\array_key_exists('animated', $options) || true !== $options['animated']) {
throw $exception;
}
$filteredFormat = 'gif';
$filteredString = $image->get($filteredFormat, $options);
}

$this->destroyImage($image);

Expand Down

0 comments on commit 977d23b

Please sign in to comment.