1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-19 12:11:26 +02:00

Add more media types to MediaTypeEncoder

This commit is contained in:
Oliver Vogel
2024-01-27 10:56:22 +01:00
parent 03a59283c3
commit 0cd5d39bcd

View File

@@ -40,15 +40,30 @@ class MediaTypeEncoder extends SpecializableEncoder implements EncoderInterface
protected function encoderByMediaType(string $type): EncoderInterface protected function encoderByMediaType(string $type): EncoderInterface
{ {
return match (strtolower($type)) { return match (strtolower($type)) {
'image/webp' => new WebpEncoder(quality: $this->quality), 'image/webp',
'image/avif' => new AvifEncoder(quality: $this->quality), 'image/x-webp' => new WebpEncoder(quality: $this->quality),
'image/jpeg' => new JpegEncoder(quality: $this->quality), 'image/avif',
'image/bmp' => new BmpEncoder(), 'image/x-avif' => new AvifEncoder(quality: $this->quality),
'image/jpeg',
'image/jpg',
'image/pjpeg' => new JpegEncoder(quality: $this->quality),
'image/bmp',
'image/ms-bmp',
'image/x-bitmap',
'image/x-bmp',
'image/x-ms-bmp',
'image/x-win-bitmap',
'image/x-windows-bmp',
'image/x-xbitmap' => new BmpEncoder(),
'image/gif' => new GifEncoder(), 'image/gif' => new GifEncoder(),
'image/png' => new PngEncoder(), 'image/png',
'image/x-png' => new PngEncoder(),
'image/tiff' => new TiffEncoder(quality: $this->quality), 'image/tiff' => new TiffEncoder(quality: $this->quality),
'image/jp2', 'image/jpx', 'image/jpm' => new Jpeg2000Encoder(quality: $this->quality), 'image/jp2',
'image/heic', 'image/heif', => new HeicEncoder(quality: $this->quality), 'image/jpx',
'image/jpm' => new Jpeg2000Encoder(quality: $this->quality),
'image/heic',
'image/heif', => new HeicEncoder(quality: $this->quality),
default => throw new EncoderException('No encoder found for media type (' . $type . ').'), default => throw new EncoderException('No encoder found for media type (' . $type . ').'),
}; };
} }