1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-21 13:11:18 +02:00

Check for existance of IMG_WEBP_LOSSLESS constant

Constant is only presnet, if the used libgd supports lossless WebP
encoding.
This commit is contained in:
Oliver Vogel
2025-01-11 17:18:03 +01:00
parent 14a7b5b24f
commit 4476d9414f

View File

@@ -18,7 +18,7 @@ class WebpEncoder extends GenericWebpEncoder implements SpecializedInterface
*/ */
public function encode(ImageInterface $image): EncodedImage public function encode(ImageInterface $image): EncodedImage
{ {
$quality = $this->quality === 100 ? IMG_WEBP_LOSSLESS : $this->quality; $quality = $this->quality === 100 && defined('IMG_WEBP_LOSSLESS') ? IMG_WEBP_LOSSLESS : $this->quality;
return $this->createEncodedImage(function ($pointer) use ($image, $quality): void { return $this->createEncodedImage(function ($pointer) use ($image, $quality): void {
imagewebp($image->core()->native(), $pointer, $quality); imagewebp($image->core()->native(), $pointer, $quality);