Repository navigation
Conversation
AVIF at quality 82 is often larger than WebP at 82, so with the JPEG fallback on, AVIF sub-sizes were thrown away as larger than the JPEG. At quality 70 AVIF looks about the same as WebP at 82 and is smaller. The quality filter now returns 70 for AVIF. Because it runs on wp_editor_set_quality, this applies to GD, Imagick and the REST image_quality field used for browser-side uploads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @jakearchibald. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #2746 +/- ##
=======================================
Coverage 70.41% 70.42%
=======================================
Files 91 91
Lines 7869 7871 +2
=======================================
+ Hits 5541 5543 +2
Misses 2328 2328
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| } | ||
|
|
||
| // Return default quality for non-WebP images in WP. | ||
| // AVIF at 82 is often larger than WebP at 82. AVIF at 70 looks about the same as WebP at 82 and is smaller. |
There was a problem hiding this comment.
Curious how these numbers was determined. They may be accurate, but "looks about the same" is vague. Consider adding some analysis like DSSIM or another more modern approach.
There was a problem hiding this comment.
other types used 82? which ones?
|
|
||
| // Return default quality for non-WebP images in WP. | ||
| // AVIF at 82 is often larger than WebP at 82. AVIF at 70 looks about the same as WebP at 82 and is smaller. | ||
| if ( 'image/avif' === $mime_type ) { |
There was a problem hiding this comment.
could be a switch statement at this point.
|
I'd like to see more research on the output quality before merging this. How did you arrive at these numbers. I support smaller files as long as we can be reasonable confident quality doesn't degrade over the default jpeg settings. I believe the formats are designed to (perhaps aspirationally) deliver the same quality at the same quality settings. Also, maybe the quality default can be even lower for avif, see: https://www.industrialempathy.com/posts/avif-webp-quality-settings/ some related previous discussion: https://core.trac.wordpress.org/ticket/54356 |
|
I see the research now on the issue, I missed it previously. See my comment there, big +1 to changing this here ASAP and also proposing for core. lets get these values as low as we can while matching jpeg's default 82 quality. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Fixes #2745
Relevant technical choices
See the linked issue for more details on how this value was determined.
This PR sets the AVIF quality to 70 in
webp_uploads_modify_webp_quality(), the same way the WebP quality is already pinned to 82.At the default quality of 82, AVIF sub-sizes come out larger than WebP and often larger than the JPEG. With "Output fallback images" enabled, most AVIF sub-sizes were then discarded. Each encoder maps the 0 to 100 number to its own quantizer, so 82 is a much higher visual quality for AVIF than for WebP. Based on the measurements in the issue, AVIF at 70 is about the same quality as WebP at 82 and is smaller.
wp_editor_set_qualityfilter, which core calls with the output mime type. So one value covers GD, Imagick and client-side media processing, which reads the same filter through theimage_qualityREST field.car.jpegis used because at quality 70 its AVIF files are smaller than the JPEG at every size with both editors, while at 82 some sizes are not.Sites without the plugin still get 82 from
WP_Image_Editor::get_default_quality(), so core needs a follow-up ticket.Use of AI Tools
Used Claude Code to trace the quality flow, run the benchmarks and write the change and tests. I reviewed the code and verified the results.