1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-29 09:47:36 +01: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
No known key found for this signature in database

View File

@ -18,7 +18,7 @@ class WebpEncoder extends GenericWebpEncoder implements SpecializedInterface
*/
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 {
imagewebp($image->core()->native(), $pointer, $quality);