AVIF support for Talkr
Talkr now has default image AVIF support. First thing, what is AVIF? AV1 Image File Format (AVIF) is an open, royalty-free image file format specification for storing images or image sequences compressed with AV1. PHP has AVIF support in its GD extension since PHP version 8.1. AVIF creates smaller images than JPG, and that is why we are using it on Talkr.app
First, we needed to make sure PHP-Gd was installed correctly without the need to recompile our PHP instance. It was indeed compiled with our PHP:
sudo apt install php8.4 php8.4-gd
Grep to see if it is compiled:
php -i | grep -i avif
Then in PHP we can now use:
imageavif($sourceImage, $targetFile, 50);
Here we copy over another image such as a JPG, convert it to AVIF and set a quality of 50.
This saves us a lot of bandwidth, as images are the main bottleneck when it comes down to a lot of traffic for a social media network site, such as Talkr. If we could cut both storage and bandwidth by a third, that would be a massive saving in terms of both storage and traffic. Which we did. It seems by now, in 2025, all major browsers support AVIF. So we are lucky we can make use of the library. All user uploaded images to Talkr, will be in AVIF format from now on.