AVIF libraries for PHP
- GD has
imagecreatefromavif()andimageavif()since PHP 8.1, when PHP’s GD is built with libavif. It’s bundled with PHP and available on most hosts, so try it first. 8-bit only. - Imagick wraps ImageMagick, which handles AVIF through libheif. Pick it when you need higher quality resizing, metadata, animated files or more formats.
Intervention Image wraps either extension with a fluent API and supports AVIF when the underlying driver does.
To check what your PHP supports: php -r 'var_dump(function_exists("imageavif"), class_exists("Imagick") && Imagick::queryFormats("AVIF"));'
- GD PHP's bundled GD extension reads and writes AVIF since PHP 8.1 with imagecreatefromavif and imageavif. How to check support, convert JPEG and PNG to AVIF.
- Imagick Imagick reads and writes AVIF in PHP with ImageMagick and libheif. How to check AVIF support, convert images to AVIF, set quality and speed, resize.