Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

Commit

Permalink
[FEATURE] Quality-Option
Browse files Browse the repository at this point in the history
  • Loading branch information
adudtkowski committed Feb 27, 2017
1 parent d6dbbcb commit 76d3d99
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Classes/Service/OptimizeImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Clickstorm\CsWebp\Service;

use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\MathUtility;

class OptimizeImageService {

Expand Down Expand Up @@ -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)) {
Expand Down
1 change: 1 addition & 0 deletions Documentation/Introduction/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions ext_conf_template.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 76d3d99

Please sign in to comment.