mirror of
https://github.com/Intervention/image.git
synced 2025-08-31 09:31:53 +02:00
Add AutoEncoder
This commit is contained in:
24
src/Encoders/AutoEncoder.php
Normal file
24
src/Encoders/AutoEncoder.php
Normal 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(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user