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

[FEATURE] using cwebp binary directly #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Classes/Service/OptimizeImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be removed or is it used anywhere?


class OptimizeImageService {
public $configuration;

/**
* Initialize
Expand Down Expand Up @@ -32,6 +34,9 @@ public function process($file, $extension = NULL) {
$webpfile = str_replace("." . $extension, ".webp", $file);
$quality = MathUtility::forceIntegerInRange($this->configuration['quality'],1,100);
$command = sprintf('convert %s -quality %s -define webp:lossless=true %s', $file, $quality, $webpfile);
if(isset($this->configuration['useCwebp']) && (bool)$this->configuration['useCwebp'] === true){
$command = sprintf('%s -q %s %s -o %s', $this->configuration['cwebpPath'], $quality, $file, $webpfile);
}
}

if (isset($command)) {
Expand Down
8 changes: 7 additions & 1 deletion ext_conf_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
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
debug = 0

# cat=basic; type=boolean; label=Use cwebp instead of imagemagick
useCwebp = 0

# cat=basic; type=string; label=path to cwebp Binary
cwebpPath = cwebp
4 changes: 2 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
'uploadfolder' => false,
'state' => 'stable',
'clearCacheOnLoad' => 1,
'version' => '1.1.2-dev',
'version' => '1.1.3',
'constraints' => [
'depends' => [
'typo3' => '7.6.0-7.9.99',
'typo3' => '7.6.0-8.7.99',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to raise the version in composer.json aswell :)

],
'conflicts' => [],
'suggests' => [],
Expand Down