Open s-sols opened 2 years ago
Confirmed, though it's a bit of jumping around to derive that value:
quantizer = (100 - quality) * (63 / 100)
QUANTIZER_DEFAULT
, which is 30.Thus a quantizer of 30 means 30 = (100 - quality) * (63 / 100)
and the quality is 52.38. Since the quality value is an integer and there is rounding at the end, 52 and 53 both work for it.
https://github.com/php/php-src/blob/PHP-8.1.9/ext/gd/libgd/gd_avif.c#L558 https://github.com/php/php-src/blob/PHP-8.1.9/ext/gd/libgd/gd_avif.c#L79 https://github.com/AOMediaCodec/libavif/blob/v0.10.1/include/avif/avif.h#L78-L80
Not sure if simply stating a default of 52/53 in the docs is the right answer. Maybe the reverse is more appropriate: that the default is a libavif quantizer value of 30, which corresponds to a medium quality of ~52. Have yet to find a nice page on the internet talking about this subject.
Thanks for the quick response, very appreciated.
I think, according to PHP 'imageavif' operates quality term instead of quantity it is better to point to 52. But U right about quantization implementation - may be type about this conversion. It gives a bonus to reader to understand how this quality is converted to quantity.
The default is 52 (or 53) due to 30 is default quantizer quality for 'avif' encoder according to source of PHP. It can be easy checked by comparing result with imageavif( $image, $file, -1 ) and imageavif( $image, $file, 52 ).