Skip to content

Commit

Permalink
Check for existance of IMG_WEBP_LOSSLESS constant
Browse files Browse the repository at this point in the history
Constant is only presnet, if the used libgd supports lossless WebP
encoding.
  • Loading branch information
olivervogel committed Jan 11, 2025
1 parent 14a7b5b commit 4476d94
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Drivers/Gd/Encoders/WebpEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4476d94

Please sign in to comment.