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

Set lossless quality for GD WebpEncoder

A value of 101 is actually specified for lossless coding with GD.
However, since Imagick expects 100 for lossless in WebP format,
I adjust this for both drivers.
This commit is contained in:
Oliver Vogel
2023-12-19 16:52:15 +01:00
parent a1da8e287a
commit bc09f0d42f

View File

@@ -13,8 +13,9 @@ class WebpEncoder extends DriverSpecializedEncoder
{ {
public function encode(ImageInterface $image): EncodedImage public function encode(ImageInterface $image): EncodedImage
{ {
$data = $this->getBuffered(function () use ($image) { $quality = $this->quality === 100 ? IMG_WEBP_LOSSLESS : $this->quality;
imagewebp($image->core()->native(), null, $this->quality); $data = $this->getBuffered(function () use ($image, $quality) {
imagewebp($image->core()->native(), null, $quality);
}); });
return new EncodedImage($data, 'image/webp'); return new EncodedImage($data, 'image/webp');