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

compression quality toggle #1698

Open
sweetrobot opened this issue Nov 25, 2024 · 8 comments
Open

compression quality toggle #1698

sweetrobot opened this issue Nov 25, 2024 · 8 comments
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Enhancement A suggestion for improvement of an existing feature

Comments

@sweetrobot
Copy link

sweetrobot commented Nov 25, 2024

Feature Description

there should be a compression quality setting - perhaps walled being an "advanced" mode toggle, or some override via a hook in functions or something -sure that's possible currently, though i'm a novice in this regard.

this was prompted because the current compression on webp (and even far more on avif) is overly agressive, and, in our use case compromises too much detail (grainy textures become soft and blurry).

@github-project-automation github-project-automation bot moved this to Not Started/Backlog 📆 in WP Performance 2024 Nov 25, 2024
@westonruter westonruter added [Type] Enhancement A suggestion for improvement of an existing feature [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) labels Nov 25, 2024
@b1ink0
Copy link
Contributor

b1ink0 commented Dec 5, 2024

@westonruter We could add new settings to the Media Settings page where we have already added some settings.

Should we add a toggle Image Compression which will be enabled by default or should we give a numeric input field to set the quality?

@westonruter
Copy link
Member

There is a filter for this actually:

// Use a quality setting of 75 for AVIF images.
function filter_avif_quality( $quality, $mime_type ) {
	if ( 'image/avif' === $mime_type ) {
		return 75;
	}
	return $quality;
}
add_filter( 'wp_editor_set_quality', 'filter_avif_quality', 10, 2 );

See the dev note from @adamsilverstein.

@sweetrobot
Copy link
Author

@westonruter does this pertain to either format - avif or webp?

@westonruter
Copy link
Member

@sweetrobot I believe you can filter WebP similarly:

function filter_webp_quality( $quality, $mime_type ) {
	if ( 'image/webp' === $mime_type ) {
		return 75;
	}
	return $quality;
}
add_filter( 'wp_editor_set_quality', 'filter_webp_quality', 10, 2 );

@adamsilverstein
Copy link
Member

this was prompted because the current compression on webp (and even far more on avif) is overly agressive, and, in our use case compromises too much detail (grainy textures become soft and blurry).

Interesting - the default quality settings are actually pretty high already so I am a bit surprised to hear that. If possible, I would love to see some before/after images where this is happening. ie if you can, please provide a sample image and the webp / avif versions that look poor to you.

As @westonruter pointed out above, compression quality is already adjustable via filters so adding UI controls for them isn't a high priority (although I am not fundamentally opposed to adding them in the plugin). Also note that starting WordPress 6.8, the filter will include size values so quality can be set on a per-size basis. See https://core.trac.wordpress.org/ticket/54648.

@sweetrobot
Copy link
Author

sweetrobot commented Dec 13, 2024

@adamsilverstein please see following for comparisons. focus especially on the wooden frame, at 100% of course.

  • video - download locally, to ensure highest quality before viewing - even with the added layer of video compression, the difference is still fully noticeable
  • original
  • webp @ 82
  • webp @ 95

in cases such as ours, fine texture details are key, and the current default setting of 82 is too aggressive

@westonruter
Copy link
Member

  • video - download locally, to ensure highest quality before viewing - even with the added layer of video compression, the difference is still fully noticeable

Even with downloading the original video file for viewing with the highest quality, the difference between the two is not fully noticeable to me. I mean, I see a difference but not really a difference in quality. The WebP version seems to have less noise, which I wouldn't say is worse. This is all subjective though.

@sweetrobot
Copy link
Author

sweetrobot commented Dec 13, 2024

@westonruter refer to the photos - swapping back and forth repeatedly, and focus on the grain (wood, rather than noise). much detail become smeared and lost entirely.

i only brought it up because i noticed the quality difference - this is without looking for it in the first place. it just hit me, because it was noticeable to me, even without the immediate back and forth flickering to compare.

i understand subjectivity plays a role, to a degree, but believe this is more than that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Enhancement A suggestion for improvement of an existing feature
Projects
Status: Not Started/Backlog 📆
Development

No branches or pull requests

4 participants