'PHP imageavif very bad quality

While converting a file from JPG to WEBP and AVIF, I noticed that the AVIF quality was very poor. I'm not talking about the "quality" parameter, it does not matter if you put 40, 60 or 80, it comes out badly.

Doing the same on sqoosh yields much better results. Any idea of what's going on?

function image($uploadedfile,$xwidth="500",$xheight="500",$qavif="50",$qwebp="75"){
  list($width,$height)=getimagesize($uploadedfile);
  $tmp=imagecreatetruecolor($xwidth,$xheight);
  imagecopyresampled($tmp,$src,0,0,0,0,$xwidth,$xheight,$width,$height);
  imagewebp($tmp,null,$qwebp);
  imageavif($tmp,null,$qavif);
  imagedestroy($src);
  imagedestroy($tmp);
}

Original JPEG

Original JPEG

WEBP Result

WEBP result

AVIF Result (look at text or circle, for example)

AVIF result



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source