diff --git a/Classes/Service/OptimizeImageService.php b/Classes/Service/OptimizeImageService.php index 0cb48fb..0156455 100644 --- a/Classes/Service/OptimizeImageService.php +++ b/Classes/Service/OptimizeImageService.php @@ -2,6 +2,7 @@ namespace Clickstorm\CsWebp\Service; use TYPO3\CMS\Core\Utility\CommandUtility; +use TYPO3\CMS\Core\Utility\MathUtility; class OptimizeImageService { @@ -29,7 +30,8 @@ public function process($file, $extension = NULL) { if ($extension == 'jpg' || $extension == 'jpeg' || $extension == 'png') { $webpfile = str_replace("." . $extension, ".webp", $file); - $command = sprintf('convert %s -define webp:lossless=true %s', $file, $webpfile); + $quality = MathUtility::forceIntegerInRange($this->configuration['quality'],1,100); + $command = sprintf('convert %s -quality %s -define webp:lossless=true %s', $file, $quality, $webpfile); } if (isset($command)) { diff --git a/Documentation/Introduction/Index.rst b/Documentation/Introduction/Index.rst index bdaac96..4054ab7 100644 --- a/Documentation/Introduction/Index.rst +++ b/Documentation/Introduction/Index.rst @@ -39,6 +39,7 @@ Installation - clear the processed images in the install tool - reload the backend - add the code in the head of your root .htaccess file. This .htaccess Code rewrites the jpg and png images to the webp files if webp is readable in the browser. +- change the level of quality if needed in the extension configuration in extension manager (default 70) .. code-block:: php diff --git a/ext_conf_template.txt b/ext_conf_template.txt index 8b6acb8..e2b325e 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -1,2 +1,5 @@ +# cat=basic/quality/500; type=integer; label=Webp Quality (0 - 100) +quality = 65 + # cat=basic/debug/1000; type=boolean; label=Enable Debugging. The output goes to backend log module when you are logged in debug = 0 \ No newline at end of file