mirror of
https://github.com/Intervention/image.git
synced 2025-08-31 01:29:51 +02:00
Refactor format detection
This commit is contained in:
@@ -140,13 +140,7 @@ class Driver extends AbstractDriver
|
||||
*/
|
||||
public function supports(string|Format|FileExtension|MediaType $identifier): bool
|
||||
{
|
||||
try {
|
||||
$format = Format::create($identifier);
|
||||
} catch (NotSupportedException) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return match ($format) {
|
||||
return match (Format::tryCreate($identifier)) {
|
||||
Format::JPEG => boolval(imagetypes() & IMG_JPEG),
|
||||
Format::WEBP => boolval(imagetypes() & IMG_WEBP),
|
||||
Format::GIF => boolval(imagetypes() & IMG_GIF),
|
||||
|
@@ -10,7 +10,6 @@ use Intervention\Image\Exceptions\DecoderException;
|
||||
use Intervention\Image\Format;
|
||||
use Intervention\Image\Interfaces\ColorInterface;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\MediaType;
|
||||
|
||||
class BinaryImageDecoder extends NativeObjectDecoder
|
||||
{
|
||||
@@ -31,10 +30,10 @@ class BinaryImageDecoder extends NativeObjectDecoder
|
||||
$image = parent::decode($imagick);
|
||||
|
||||
// get media type enum from string media type
|
||||
$mediaType = MediaType::from($image->origin()->mediaType());
|
||||
$format = Format::tryCreate($image->origin()->mediaType());
|
||||
|
||||
// extract exif data for appropriate formats
|
||||
if (in_array($mediaType->format(), [Format::JPEG, Format::TIFF])) {
|
||||
if (in_array($format, [Format::JPEG, Format::TIFF])) {
|
||||
$image->setExif($this->extractExifData($input));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user