Skip to content

Commit

Permalink
Merge pull request #1444 from liip/gif_shoud_not_be_transformed_to_we…
Browse files Browse the repository at this point in the history
…bp_format

animated gifs can not be transformed to the webp format
  • Loading branch information
dbu authored Jan 11, 2022
2 parents 66f5cdf + 977d23b commit af61a40
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 af61a40

Please sign in to comment.