AVIF Optimization Guide
Best practices for optimizing AVIF images for maximum compression and web performance.
By the CompressItAll team. Published 2025-11-23. Updated 2026-10-24.
Quick Optimization Checklist
- ✓ Pick quality by eye, one content type at a time
- ✓ Use a mid-range encoder speed for balanced encode time and size
- ✓ Use 4:2:0 chroma subsampling for photos, full color resolution for graphics
- ✓ Implement fallbacks with
<picture> - ✓ Resize images before conversion
- ✓ Test file sizes against WebP/JPEG
- ✓ Use lazy loading for below-fold images
1. Quality Settings (Quantizer Values)
In libaom, AVIF quality is controlled by a quantizer scale from 0 to 63, as defined in the AV1 specification (Alliance for Open Media). Low values mean high quality and high values mean low quality. The ranges below are rough guidance only, so judge results by eye:
| Quantizer Range | Quality | Use Case |
|---|---|---|
| 0-15 | Highest quality | Critical images, large files |
| 16-23 ✓ | Excellent | Recommended for photos |
| 24-32 | Good | Aggressive compression |
| 33-51 | Lower quality | Maximum compression |
| 52-63 | Lowest quality | Not lossless. Lossless is a separate encoder mode |
2. Encoding Speed Settings
AVIF encoders offer speed presets (0-10) trading encoding time for file size/quality:
- Speed 0-2: Slowest, best compression for the quality
- Speed 3-5: Balanced, a sensible default
- Speed 6-8: Faster, with some loss of compression efficiency
- Speed 9-10: Fastest, with the weakest compression
3. Chroma Subsampling
- 4:4:4: No subsampling - use for graphics, logos, screenshots
- 4:2:0: Standard subsampling - use for photographs ⭐ Recommended
4. Browser Support & Fallbacks
Always provide WebP and JPEG fallbacks:
<picture>
<source srcset="image.avif" type="image/avif">
<source srcset="image.webp" type="image/webp">
<img src="image.jpg" alt="Description" loading="lazy">
</picture>5. Responsive Images
Serve different sizes based on viewport:
<picture>
<source
type="image/avif"
srcset="hero-400w.avif 400w, hero-800w.avif 800w, hero-1200w.avif 1200w"
sizes="(max-width: 640px) 100vw, (max-width: 1024px) 80vw, 1200px">
<source
type="image/webp"
srcset="hero-400w.webp 400w, hero-800w.webp 800w, hero-1200w.webp 1200w"
sizes="(max-width: 640px) 100vw, (max-width: 1024px) 80vw, 1200px">
<img
src="hero-1200w.jpg"
alt="Hero"
loading="lazy"
width="1200"
height="600">
</picture>6. Performance Tips
- Batch Process: Encode AVIF during build, not runtime
- CDN Transcoding: Use services like Cloudflare Images
- Lazy Loading: Use
loading="lazy"for below-fold - Dimensions: Always set width/height to prevent layout shift
- Testing: Verify AVIF is actually smaller than WebP/JPEG
7. When NOT to Use AVIF
- Supporting IE11 or Safari before 16.4 is critical and you cannot add a fallback
- Real-time encoding is required (too slow)
- Animated content where tool and player support matters more than size
- The size difference from WebP is too small to justify the slower encoding
How AVIF Encoding Works, Briefly
AVIF stores a still image using the AV1 video codec inside a HEIF container. The encoder splits the picture into blocks and predicts each block from pixels it has already coded. Prediction in AV1 includes 56 directional intra modes, built from 8 nominal angles with offsets in steps of 3 degrees, plus non-directional modes. Only the difference between the prediction and the real pixels is transformed, quantised and stored. Better prediction leaves less to store, which is a large part of why AVIF can reach small files on photographs. The cost is that the encoder has many options to evaluate, so encoding is slower than JPEG or WebP.
What the Quality Scale Really Means
Encoders such as libaom expose a quantizer scale from 0 to 63. Low values mean high quality and large files, and high values mean low quality and small files. The top of the scale is the worst quality, not the best, so a value of 63 is definitely not lossless. Lossless AVIF is a separate encoder mode that skips quantisation of the image data. Many tools hide this scale behind a 0 to 100 quality slider where higher is better, which is the convention our tool uses. Check which direction a tool uses before copying numbers from a tutorial.
A Sensible Settings Workflow
- Resize the source to the largest size it will be displayed at. Pixel count has more effect than any quality setting.
- Encode at a moderate quality and view the result at 100 percent zoom next to the original.
- Lower quality in steps until you can see a difference in smooth areas, text edges or faces, then step back up one notch.
- Repeat for each content type. A busy landscape tolerates more reduction than a portrait with soft skin.
- Compare the final AVIF against a WebP or JPEG of similar appearance. If the saving is small, the extra encoding time is not worth it for that image.
Using the CompressItAll AVIF Tool
The AVIF compressor accepts up to 5 files per batch. Lossy mode starts at a quality of 85 and Lossless keeps the pixel data. Custom mode has quality, target size and maximum dimension fields, but they are not applied reliably yet. Read the sizes in the results table and use the before and after view to check for smearing. Files are uploaded over HTTPS, deleted automatically after processing, and no registration is needed. You can download files individually or as a ZIP.
Chroma Subsampling Choices
Subsampling stores color at lower resolution than brightness. For photographs this is nearly invisible and saves data. For screenshots, thin colored text, and sharp colored lines on contrasting backgrounds, reduced color resolution shows up as fringing, so keep full-resolution color for that material. For those images, also compare the result with PNG, which may be the better choice as covered in PNG Optimization Best Practices.
Delivery: Dimensions, Lazy Loading, and Layout Shift
Small files only help if the page uses them well. Give every image explicit width and height attributes so the browser reserves space and the layout does not jump when it loads. Use lazy loading for images below the first screen, but not for the main image at the top of the page, which should load right away. Serve several widths with srcset and sizes so a phone is not sent the desktop version. Generate all variants at build time or upload time. Do not encode AVIF on demand for each visitor, because encoding is the slow part.
Handling Color and HDR
AVIF can carry wide color gamut and HDR data, but a picture that was converted without its color profile can look flat or oversaturated. If the source uses a wide gamut profile, check how it appears in more than one browser. When the target is ordinary web display, converting to sRGB before encoding avoids surprises.
Common Mistakes
- Copying quality numbers from a tutorial that uses the opposite direction for its scale.
- Treating the highest quantizer value as lossless.
- Shipping AVIF with no fallback for browsers that lack support.
- Lazy loading the hero image, which delays the most visible content.
- Skipping the resize step and encoding a camera original at full resolution.
- Using aggressive settings on text-heavy images and accepting smeared edges.
Troubleshooting
- The AVIF is larger than the JPEG. The source may already be heavily compressed, or the quality setting is much higher than the JPEG used. Compare at a similar visual quality, and try a lower setting.
- Skies or gradients show bands. Raise quality for that image or add a little noise at export time, since smooth areas are where banding appears first.
- Colors look dull. Check the color profile and convert to sRGB.
- Encoding takes too long. Use a faster encoder speed preset in your own pipeline, or encode once at build time and cache the result.
- An image does not display on an older device. Confirm the
<picture>fallbacks exist and the JPEG or WebP file is present at the path given.
Final Checklist
- Image resized to its display size.
- Quality chosen by eye, one content type at a time.
- Browser support: Chrome 85+, Firefox 93+, Safari 16.4+, Edge 121+ (caniuse), with fallbacks for everything else.
- Width and height set, lazy loading used only below the first screen.
- Encoding done ahead of time, not per request.
For the background on why these settings behave as they do, see How AVIF Compression Works. To decide whether AVIF is the right pick at all, read AVIF vs WebP vs JPEG.
Start Optimizing AVIF Images
Use our free online AVIF compressor with optimized quality presets. No registration required.
Compress AVIF Images Now →