11ty / eleventy-img

Utility to perform build-time image transformations.
https://www.11ty.dev/docs/plugins/image/
436 stars 55 forks source link

Change AVIF quality defaults #198

Open zachleat opened 12 months ago

zachleat commented 12 months ago

Read: https://tsev.dev/posts/2023-11-10-should-avif-be-the-dominant-image-format/

As we discovered, AVIF often is more accurate and smaller in file size than competing image formats. A quality setting of 60-70% is a good place to start where perceivable accuracy is consistent enough across images without exploding in file size. At the cost of accuracy, we can lower it to 50%, but anything lower typically comes with bad artefacts. I recommend staying below 80% as any value higher is indistinguishable. If you care about improved pixel accuracy, JPEG might give you that at a smaller file size.

zachleat commented 9 months ago

I did find out later that the Sharp library we use upstream has a default quality of 50 so I think we can close this one as solved.

https://sharp.pixelplumbing.com/api-output#avif

eeeps commented 1 month ago

Different AVIF encoders have different effort and quality scales and I don't know how Sharp's are set up (it seems to use libaom, but maybe with a flipped "effort" (vs "speed") scale??)

Anyways when doing a test with one (1) image, I thought the output looked a bit crummy and turned up both the quality and effort – and was happier.

Here are some loosely-held beliefs:

I chose effort 7 and quality 70 because they fit nicely within these guidelines and I used to always encode my JPEGs at Save for Web... quality 72 and you know 70 is pretty close to that.

Here are the images:

Original: https://o.img.rodeo/w_800/dogs/2.png Default settings (quality 50, effort 4): https://o.img.rodeo/w3fr2wrmmrf3pfrtmal7.avifcompared to original Custom settings (quality 70, effort 7): https://o.img.rodeo/vahj96nhy8xchvlodlbo.avifcompared to original

(Note that the comparison pages display the images at 1x...)

Clearly, some more rigorous investigation is in order. But this first experience with eleventy-img made me hypothesize that the defaults could and maybe should be higher.

lovell commented 1 month ago

Upstream discussion at https://github.com/lovell/sharp/issues/4227