$mimetype = $img->getType();
}
- // if customsize is set and image resizing is supported for this image, resize it
- if (Images::canResize($photo['type']) && $customsize > 0 && $customsize <= Proxy::PIXEL_THUMB && $square_resize) {
+ // if customsize is set and image is not a gif, resize it
+ if ($photo['type'] !== image_type_to_mime_type(IMAGETYPE_GIF) && $customsize > 0 && $customsize <= Proxy::PIXEL_THUMB && $square_resize) {
$img = new Image($imgdata, $photo['type'], $photo['filename']);
$img->scaleToSquare($customsize);
$imgdata = $img->asString();
$mimetype = $img->getType();
- } elseif (Images::canResize($photo['type']) && $customsize > 0) {
+ } elseif ($photo['type'] !== image_type_to_mime_type(IMAGETYPE_GIF) && $customsize > 0) {
$img = new Image($imgdata, $photo['type'], $photo['filename']);
$img->scaleDown($customsize);
$imgdata = $img->asString();
// stop.
}
- // reduce quality - if it is supported for this image type
- if (Images::canResize($image->getType())) {
+ // reduce quality - if it isn't a GIF
+ if ($image->getImageType() != IMAGETYPE_GIF) {
$image->scaleDown($request['size']);
}
if (Images::isSupportedMimeType($type)) {
$this->imageType = Images::getImageTypeByMimeType($type);
- } elseif (($type == '') || substr($type, 0, 6) == 'image/' || substr($type, 0, 12) == ' application/') {
+ } elseif (($type == '') || substr($type, 0, 6) != 'image/' || substr($type, 0, 12) != ' application/') {
$this->imageType = IMAGETYPE_WEBP;
DI::logger()->debug('Unhandled image mime type, use WebP instead', ['type' => $type, 'filename' => $filename, 'size' => strlen($data)]);
} else {
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
*