![](https://keeplearning.dev/images/featured/how-php-works-internally-580330dac749.png)
PHP
With the latest PHP 8.1 update bringing a host of improvements and new features, PHP web development has never been more exciting. One notable feature is the introduction of the GD: AVIF image support. Let's get into the details.
GD is a powerful open-source code library used for creating and manipulating images dynamically. AVIF, on the other hand, is a new image format based on the modern AV1 video codec. It offers superior compression and efficiency over older image formats, without compromising on quality. In PHP 8.1, GD: AVIF Image Support refers to the addition of functions to handle AVIF images using the GD library.
AVIF holds a lot of promises and benefits for web developers and users. This new image format offers better compression than legacy formats like JPEG and PNG. This means that AVIF images use less storage and bandwidth, resulting in faster loading times and improved website performance.
The latest PHP 8.1 release integrated AVIF support into the GD library, thus providing developers with the ability to create, edit, and manipulate AVIF images. This integration can be beneficial for developers as it lets them reduce the size of images in their applications, thereby contributing to an improved user experience.
With PHP 8.1, also we have some new functions.
function imagecreatefromavif(string $filename): GdImage|false {}
/**
* @param resource|string|null $file
*/
function imageavif(GdImage $image, $file = null, int $quality = -1, int $speed = -1): bool {}
imagecreatefromavif function returns a new GdImage instance from a given AVIF image. For more details, you can check the PHP manual.
imageavif function outputs the file. For more details, you can check the PHP manual.
This is the basic example with the new imageavif function.
$image = imagecreatefromjpeg('ex.jpeg');
imageavif($image, 'ex.avif');