-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #198 from 0xb4lint/avif-support
added AVIF support
- Loading branch information
Showing
17 changed files
with
147 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Spatie\ImageOptimizer\Optimizers; | ||
|
||
use Spatie\ImageOptimizer\Image; | ||
|
||
class Avifenc extends BaseOptimizer | ||
{ | ||
public $binaryName = 'avifenc'; | ||
public $decodeBinaryName = 'avifdec'; | ||
|
||
public function canHandle(Image $image): bool | ||
{ | ||
return $image->mime() === 'image/avif' || $image->extension() === 'avif'; | ||
} | ||
|
||
public function getCommand(): string | ||
{ | ||
$this->tmpPath = tempnam(sys_get_temp_dir(), 'avifdec') . '.png'; | ||
|
||
$decodeOptionString = implode(' ', [ | ||
'-j all', | ||
'--ignore-icc', | ||
'--no-strict', | ||
'--png-compress 0', | ||
]); | ||
$encodeOptionString = implode(' ', $this->options); | ||
|
||
$decode = "\"{$this->binaryPath}{$this->decodeBinaryName}\" {$decodeOptionString}" | ||
.' '.escapeshellarg($this->imagePath) | ||
.' '.escapeshellarg($this->tmpPath); | ||
|
||
$encode = "\"{$this->binaryPath}{$this->binaryName}\" {$encodeOptionString}" | ||
.' '.escapeshellarg($this->tmpPath) | ||
.' '.escapeshellarg($this->imagePath); | ||
|
||
return $decode . ' && ' . $encode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.