1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-19 04:01:30 +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
{
$data = $this->getBuffered(function () use ($image) {
imagewebp($image->core()->native(), null, $this->quality);
$quality = $this->quality === 100 ? IMG_WEBP_LOSSLESS : $this->quality;
$data = $this->getBuffered(function () use ($image, $quality) {
imagewebp($image->core()->native(), null, $quality);
});
return new EncodedImage($data, 'image/webp');