Skip to content

Commit

Permalink
Encode webp lossless with Imagick WebpEncoder and quality of 100
Browse files Browse the repository at this point in the history
Matches behaviour of GD encoder.
  • Loading branch information
olivervogel committed Jan 17, 2025
1 parent 0cd29e6 commit 5d64da9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Drivers/Imagick/Encoders/WebpEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public function encode(ImageInterface $image): EncodedImageInterface
$imagick->setImageCompression($compression);
$imagick->setImageCompressionQuality($this->quality);

if ($this->quality === 100) {
$imagick->setOption('webp:lossless', 'true');
}

return new EncodedImage($imagick->getImagesBlob(), 'image/webp');
}
}

0 comments on commit 5d64da9

Please sign in to comment.