1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-23 05:52:47 +02:00

Handle non-standard but still in use image/x-jpeg mimetype as JPEG (#1372)

* Handle non-standard but still in use image/x-jpeg mimetype as JPEG

* Fix test
This commit is contained in:
Philippe Lonchampt
2024-07-02 17:53:07 +02:00
committed by GitHub
parent 137bdb356a
commit 4bc03a2304
3 changed files with 7 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ enum MediaType: string
case IMAGE_JPEG = 'image/jpeg';
case IMAGE_JPG = 'image/jpg';
case IMAGE_PJPEG = 'image/pjpeg';
case IMAGE_X_JPEG = 'image/x-jpeg';
case IMAGE_WEBP = 'image/webp';
case IMAGE_X_WEBP = 'image/x-webp';
case IMAGE_GIF = 'image/gif';
@@ -41,7 +42,8 @@ enum MediaType: string
return match ($this) {
self::IMAGE_JPEG,
self::IMAGE_JPG,
self::IMAGE_PJPEG => Format::JPEG,
self::IMAGE_PJPEG,
self::IMAGE_X_JPEG => Format::JPEG,
self::IMAGE_WEBP,
self::IMAGE_X_WEBP => Format::WEBP,
self::IMAGE_GIF => Format::GIF,

View File

@@ -43,7 +43,7 @@ final class FormatTest extends BaseTestCase
$format = Format::JPEG;
$mediaTypes = $format->mediaTypes();
$this->assertIsArray($mediaTypes);
$this->assertCount(3, $mediaTypes);
$this->assertCount(4, $mediaTypes);
}
public function testMediaTypesWebp(): void

View File

@@ -20,6 +20,9 @@ final class MediaTypeTest extends BaseTestCase
$mime = MediaType::IMAGE_JPG;
$this->assertEquals(Format::JPEG, $mime->format());
$mime = MediaType::IMAGE_X_JPEG;
$this->assertEquals(Format::JPEG, $mime->format());
}
public function testFormatWebp(): void