diff --git a/inc/Service/Media/MimeMapMediaHandler.php b/inc/Service/Media/MimeMapMediaHandler.php index 22550e04..39ca2d5f 100644 --- a/inc/Service/Media/MimeMapMediaHandler.php +++ b/inc/Service/Media/MimeMapMediaHandler.php @@ -13,28 +13,13 @@ class MimeMapMediaHandler implements MediaHandler { */ private mixed $mime_mapper; - private static function getShape(string $file_path) { - $ret = \getimagesize($file_path); - if ($ret === false) { - throw new MediaException("Could not read image sizes of '$file_path'", MediaException::ERR_NO_OPEN); - } - if ($ret[2] == \IMAGETYPE_UNKNOWN) { - throw new \RuntimeException("Error '$file_path' is not an image", MediaException::ERR_BAD_MEDIA_TYPE); - } - - $width = $ret[0]; - $height = $ret[1]; - $mime = $ret['mime']; - return [ $width, $height, $mime ]; - } - private function generateThumbImpl( string $source_file_mime, int $max_width, int $max_height ): ThumbGenerationResult { $thumb_path = ($this->mime_mapper)($source_file_mime); - list($thumb_width, $thumb_height, $thumb_mime) = self::getShape($thumb_path); + list($thumb_width, $thumb_height, $thumb_mime) = Metadata\sniff_image($thumb_path); return new ThumbGenerationResult( $thumb_path,