@@ 7-24 (lines=18) @@ | ||
4 | ||
5 | use Spatie\ImageOptimizer\Image; |
|
6 | ||
7 | class Cwebp extends BaseOptimizer |
|
8 | { |
|
9 | public $binaryName = 'cwebp'; |
|
10 | ||
11 | public function canHandle(Image $image): bool |
|
12 | { |
|
13 | return $image->mime() === 'image/webp'; |
|
14 | } |
|
15 | ||
16 | public function getCommand(): string |
|
17 | { |
|
18 | $optionString = implode(' ', $this->options); |
|
19 | ||
20 | return "\"{$this->binaryPath}{$this->binaryName}\" {$optionString}" |
|
21 | .' '.escapeshellarg($this->imagePath) |
|
22 | .' -o '.escapeshellarg($this->imagePath); |
|
23 | } |
|
24 | } |
|
25 |
@@ 7-24 (lines=18) @@ | ||
4 | ||
5 | use Spatie\ImageOptimizer\Image; |
|
6 | ||
7 | class Pngquant extends BaseOptimizer |
|
8 | { |
|
9 | public $binaryName = 'pngquant'; |
|
10 | ||
11 | public function canHandle(Image $image): bool |
|
12 | { |
|
13 | return $image->mime() === 'image/png'; |
|
14 | } |
|
15 | ||
16 | public function getCommand(): string |
|
17 | { |
|
18 | $optionString = implode(' ', $this->options); |
|
19 | ||
20 | return "\"{$this->binaryPath}{$this->binaryName}\" {$optionString}" |
|
21 | .' '.escapeshellarg($this->imagePath) |
|
22 | .' --output='.escapeshellarg($this->imagePath); |
|
23 | } |
|
24 | } |
|
25 |