| @@ 7-22 (lines=16) @@ | ||
| 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->binaryName} {$optionString} '{$this->imagePath}' --output='{$this->imagePath}'"; |
|
| 21 | } |
|
| 22 | } |
|
| 23 | ||
| @@ 7-27 (lines=21) @@ | ||
| 4 | ||
| 5 | use Spatie\ImageOptimizer\Image; |
|
| 6 | ||
| 7 | class Svgo extends BaseOptimizer |
|
| 8 | { |
|
| 9 | public $binaryName = 'svgo'; |
|
| 10 | ||
| 11 | public function canHandle(Image $image): bool |
|
| 12 | { |
|
| 13 | if ($image->extension() !== 'svg') { |
|
| 14 | ||
| 15 | return false; |
|
| 16 | } |
|
| 17 | ||
| 18 | return $image->mime() === 'text/html'; |
|
| 19 | } |
|
| 20 | ||
| 21 | public function getCommand(): string |
|
| 22 | { |
|
| 23 | $optionString = implode(' ', $this->options); |
|
| 24 | ||
| 25 | return "{$this->binaryName} {$optionString} --input='{$this->imagePath}' --output='{$this->imagePath}'"; |
|
| 26 | } |
|
| 27 | } |
|
| 28 | ||