Fix the handling of unhandled image types and of animations (#13904)

* Fix the handling of unhandled image types and of animations

* Avoid warnings
This commit is contained in:
Michael Vogel 2024-02-17 15:46:48 +01:00 committed by GitHub
parent 7d10518e94
commit 08fa51d0bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 8 deletions

View file

@ -183,6 +183,21 @@ class Images
return $types;
}
/**
* Checks if the provided mime type can be handled for resizing.
* Only with Imagick installed, animated GIF and WebP keep their animation after resize.
*
* @param string $mimetype
* @return boolean
*/
public static function canResize(string $mimetype): bool
{
if (in_array(self::getImageTypeByMimeType($mimetype), [IMAGETYPE_GIF, IMAGETYPE_WEBP])) {
return class_exists('Imagick');
}
return true;
}
/**
* Fetch image mimetype from the image data or guessing from the file name
*