mirror of
https://github.com/Intervention/image.git
synced 2025-08-20 04:31:24 +02:00
Add AVIF support to GD Encoder
This commit is contained in:
@@ -147,9 +147,23 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
|||||||
*/
|
*/
|
||||||
protected function processAvif()
|
protected function processAvif()
|
||||||
{
|
{
|
||||||
throw new NotSupportedException(
|
if ( ! function_exists('imageavif')) {
|
||||||
"AVIF format is not supported by Gd Driver."
|
throw new NotSupportedException(
|
||||||
);
|
"AVIF format is not supported by PHP installation."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$resource = $this->image->getCore();
|
||||||
|
imagepalettetotruecolor($resource);
|
||||||
|
imagealphablending($resource, true);
|
||||||
|
imagesavealpha($resource, true);
|
||||||
|
imageavif($resource, null, $this->quality);
|
||||||
|
$this->image->mime = defined('IMAGETYPE_AVIF') ? image_type_to_mime_type(IMAGETYPE_AVIF) : 'image/avif';
|
||||||
|
$buffer = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user