1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-30 09:10:21 +02:00

Add AutoEncoder

This commit is contained in:
Oliver Vogel
2023-12-16 09:17:53 +01:00
parent cf1958c6e8
commit dbe27c6ab5

View File

@@ -0,0 +1,24 @@
<?php
namespace Intervention\Image\Encoders;
use Intervention\Image\Interfaces\EncodedImageInterface;
use Intervention\Image\Interfaces\EncoderInterface;
use Intervention\Image\Interfaces\ImageInterface;
class AutoEncoder implements EncoderInterface
{
public function encode(ImageInterface $image): EncodedImageInterface
{
return $image->encode(
match ($image->origin()->mimetype()) {
'image/webp' => new WebpEncoder(),
'image/avif' => new AvifEncoder(),
'image/jpeg' => new JpegEncoder(),
'image/bmp' => new BmpEncoder(),
'image/gif' => new GifEncoder(),
default => new PngEncoder(),
}
);
}
}