Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change AVIF quality defaults #198

Open
zachleat opened this issue Nov 14, 2023 · 3 comments
Open

Change AVIF quality defaults #198

zachleat opened this issue Nov 14, 2023 · 3 comments
Labels
enhancement New feature or request on hold

Comments

@zachleat
Copy link
Member

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 zachleat added the enhancement New feature or request label Nov 14, 2023
@zachleat
Copy link
Member Author

zachleat commented Feb 6, 2024

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

@zachleat zachleat closed this as completed Feb 6, 2024
@eeeps
Copy link

eeeps commented Oct 1, 2024

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:

  • Many AVIF tools are built on AV1 toolchains, and have defaults tuned for video, which produce much lower quality than you'd want for images.
  • (unless those images are being displayed at >=2x, then it might be fine, sometimes. Might not tho.)
  • The last two effort/speed levels are almost never usable, in any AVIF encoder. Way too crappy at the fast end, and painfully slow at the slow end.

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
Copy link

lovell commented Oct 3, 2024

Upstream discussion at lovell/sharp#4227

@zachleat zachleat added this to the Eleventy Image v6.0.0 milestone Dec 13, 2024
@zachleat zachleat removed this from the Eleventy Image v6.0.0 milestone Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request on hold
Projects
None yet
Development

No branches or pull requests

3 participants