From c1814c8e6b6535cc195b149895dd940f2f9fc856 Mon Sep 17 00:00:00 2001 From: horst-n Date: Wed, 24 Apr 2019 21:28:33 +0200 Subject: [PATCH] add option webpQuality --- wire/core/ImageSizerEngine.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/wire/core/ImageSizerEngine.php b/wire/core/ImageSizerEngine.php index 6268044f..8f2edb91 100755 --- a/wire/core/ImageSizerEngine.php +++ b/wire/core/ImageSizerEngine.php @@ -11,6 +11,7 @@ * @property bool $interlace * @property array|string|bool $cropping * @property int $quality + * @property int $webpQuality * @property string $sharpening * @property float $defaultGamma * @property float $scale @@ -60,6 +61,14 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable */ protected $quality = 90; + /** + * WebP Image quality setting, 1..100 + * + * @var int + * + */ + protected $webpQuality = 90; + /** * Image interlace setting, false or true * @@ -219,6 +228,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable 'cropping', 'interlace', 'quality', + 'webpQuality', 'sharpening', 'defaultGamma', 'scale', @@ -889,6 +899,22 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable return $this; } + /** + * Set the image quality 1-100 for WebP output, where 100 is highest quality + * + * @param int $n + * + * @return $this + * + */ + public function setWebpQuality($n) { + $n = (int) $n; + if($n < 1) $n = 1; + if($n > 100) $n = 100; + $this->webpQuality = (int) $n; + return $this; + } + /** * Given an unknown sharpening value, return the string representation of it * @@ -1116,6 +1142,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable * * @param array $options May contain the following (show with default values): * 'quality' => 90, + * 'webpQuality' => 90, * 'cropping' => true, * 'upscaling' => true, * 'autoRotation' => true, @@ -1148,6 +1175,9 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable case 'quality': $this->setQuality($value); break; + case 'webpQuality': + $this->setWebpQuality($value); + break; case 'cropping': $this->setCropping($value); break; @@ -1207,6 +1237,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable $options = array( 'quality' => $this->quality, + 'webpQuality' => $this->webpQuality, 'cropping' => $this->cropping, 'upscaling' => $this->upscaling, 'interlace' => $this->interlace,