AVIF turns my gradients into banded garbage, what gives?

da_real_mvp

New Member
Messages
69
Reaction score
0
Location
Atlanta, GA

Been slowly moving my photo portfolio over to AVIF because the file sizes are stupid good (300KB vs 1.2MB for the same shot) and I was feeling all smug about it. Then I opened the sky in one of my landscape edits and it's literally stripes. Not subtle banding either, proper posterized garbage. Same source PNG, same Squoosh settings, quality 50, effort 6.

What's weird is skin tones and foliage look totally fine. It's only smooth gradients that fall apart. WebP at 80 doesn't do this nearly as bad, but the files are way bigger. Is this just an AVIF thing at lower quality? Do I need to bump quality or is there some chroma setting I'm missing?

If you've actually shipped AVIF to clients I'd love to hear what settings survive. I'm not going back to JPEG for a portfolio that loads this fast, but I also can't have skies looking like a 2008 GIF.

jt_loves_tacos

New Member
Messages
75
Reaction score
0
Location
Phoenix, AZ

Quality 50 is your whole problem, honestly. AVIF's quality slider in Squoosh maps way more aggressively than WebP's does, so 50 there is closer to WebP at 55-60 in terms of what it's actually throwing away. Gradients are the first thing to go because the encoder runs out of precision in smooth areas before anything else.

Two things that fixed this for me:

  • Encode 10-bit even from an 8-bit source. Sounds like it shouldn't matter, costs basically nothing in file size, and the banding just disappears. Squoosh doesn't expose bit depth last I checked, which is why everyone hits this exact wall in Squoosh specifically and nowhere else.
  • Mess with cq-level instead of the quality number if you switch to avifenc or sharp. I land around 24-26 for portfolio stuff. Pushing past 30 on skies and you're rolling dice with the banding.

A tiny bit of grain before export also does wonders. Like a 2-3% noise layer, nothing you'd notice at 100%. Acts as dither and the encoder stops trying to posterize the sky. Feels like cheating but it works.

The foliage and skin looking fine is the tell, btw. All that high frequency detail gives the encoder somewhere to hide the loss. A flat sky is just naked.

jt_loves_tacos

New Member
Messages
75
Reaction score
0
Location
Phoenix, AZ

One caveat on the grain thing though, don't just slap it on everything. If you're doing it on a dark or night sky it can turn into a mushy mess because now the encoder has to spend bits on noise AND the gradients. I burned a whole evening on a night shot before I figured that out. On bright daytime skies it's a nearly free fix.

Also worth saying, effort 6 in Squoosh is doing you no favors here. If you're going to stay in Squoosh, crank effort to 8 or 9, quality 70+, and accept the bigger file. The effort setting controls how hard it searches for the best way to encode, and at effort 6 with quality 50 it's basically not looking hard enough in smooth areas. The whole reason avifenc feels like a different encoder is that you actually get to tell it what to care about.

The 10-bit tip is the one that actually matters long term, but heads up, not every browser/toolchain handles 10-bit AVIF perfectly on decode. I've had it look fine in Chrome and Firefox and then get weird in an older Android WebView. Test on the actual things you care about before you ship a client gallery.

What's your source pipeline? If you're going Lightroom to PNG, there might be a dither step in the export you can turn on that gets you most of the way without touching grain.

xNova_

New Member
Messages
57
Reaction score
0
Location
Toronto, ON

the 10-bit thing is the real answer, but honestly just ditch Squoosh. It's basically unmaintained at this point and shipping an ancient libavif build, so you're not really testing AVIF vs WebP, you're testing 2022 AVIF vs WebP. I moved to avifenc through a dumb little shell script and the same source at the same output size came out visibly cleaner. Not subtle either.

Second thing nobody's brought up: chroma subsampling. avifenc defaults to 4:2:0 and Squoosh doesn't even expose the option. For skies where the banding lives in the color as much as the luminance, --yuv 444 is the difference between smooth and stair-stepped. Costs maybe 10-15% file size, so I only do it on hero images, not a 60 shot gallery.

Grain works but I'd be careful with it. Had a client zoom in on a 4K display and ask why the sky looked dusty, which was not a fun email to write back. Now I grain my own web exports and leave delivered files alone.

Are you scripting avifenc per file or batching through sharp? I've been meaning to compare the two on the same source and never get around to it.

FrostyBear

New Member
Messages
67
Reaction score
0
Location
Brisbane, AU

Wait, hold on. The 10-bit thing is news to me. I've been encoding from 8-bit PNGs this whole time and just assumed there was nothing to gain there, so that explains a LOT about why my sunsets look like a paint-by-numbers kit.

The dusty sky story from xNova_ is making me nervous though. I threw grain on like 20 shots last week and now I'm second guessing all of them. Did you catch it on the client's screen or on yours first?

Also, dumb question since I'm still living in Squoosh land: how hard is the avifenc setup actually? I keep seeing "just script it" like everyone already knows how and I'm over here googling what a shell script even is, lol.

You must log in or register to reply here.