I have this code to save an AVIF image :
if (class_exists('Imagick')) {
$image = new Imagick();
$image->readImage($file); // $file was defined before
$image->setImageFormat('avif');
//$image->setImageCompressionQuality($compression_quality); // defined before, default $compression_quality = 25
//$image->setOption('heic:speed', 5);
$image->writeImage($output);
}
I commented out the two options with which I tried to control the AVIF image quality. Whichever option I'm using, or both of them, the produced image size is the same. The image successfully appears under Chrome or Firefox.
I read the code here : https://github.com/ImageMagick/ImageMagick/blob/main/coders/heic.c and it looks to me that both options should work...
I can't use the php 8.1 imageavif function so Imagick is the only option left for me (don't bother answering 'use imageavif')
Versions used on my dev computer : Ubuntu 22.04, Imagemagick 7.1.0, Imagick 3.7.0, libheif 1.12
Could anyone show me how to save an AVIF image and control compression and speed using Imagick ? (and please show me how to use the chroma option if you have the time, 4:2:2 looks fine to me)
Thanks