Opened 3 years ago
Last modified 17 months ago
#55036 assigned enhancement
Sharpen thumbnails with Imagick adaptiveSharpenImage()
Reported by: | galbaras | Owned by: | antpb |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 5.9 |
Component: | Media | Keywords: | needs-patch needs-testing close |
Focuses: | Cc: |
Description
The Imagick function resizeImage()
often produces thumbnails with a low visual quality (blurry/grainy). The world is moving to small high-resolution devices, where visual quality makes a difference, and we need something better.
Fortunately, adaptiveSharpenImage()
(see https://www.php.net/manual/en/imagick.adaptivesharpenimage.php) sharpens the subject/foreground of the image, while not sharpening the background (as much).
I've tested it with various sigma
values, and 1
got me a nice enough result (radius
was 0
== auto). However, it would be good to test ranges of image sizes and ranges of scaling ratios (original size / thumbnail size) to find out more.
For even more flexibility, there should be filters on the default values of radius
and sigma
. This will allow developers to have finer control on specific sites that need a bit more.
Alternatively, add_media_size()
can be extended to accept radius
and sigma
, which can then be used during thumbnail generation. This will also be a convenient way for developers to update the sharpening settings of existing media sizes.
Option: when Imagick is used, add radius
and sigma
fields to the definition of image sizes in Settings > Media -OR- in the customizer for site-specific control without coding.
See also: #40415
Change History (16)
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
2 years ago
#3
@
2 years ago
This is now implemented in the EWWW Image Optimizer plugin following some serious investigation. Integrating into core shouldn't be too difficult.
This ticket was mentioned in Slack in #core by costdev. View the logs.
21 months ago
#5
@
21 months ago
A few tests would be recommended (not all images are improved by sharpening, but we might find most thumbnails could be); there is a performance risk; and a possible "10% of an increase in file size".
The patch might need to provide a way to toggle this feature on/off, and customise the radius/sigma.
Checking the EWWW Image Optimizer plugin (lines 436 to 441):
ewww_image_optimizer_sharpen
appears to be off by default (as an aside, eio_use_adaptive_sharpen is also false by default, but eio_enable_adaptive_sharpen seems to ignore this second step, and instead does a check for 1.5+ MP images);- Used with JPEG images (WebP images are done separately);
- Checks the Imagick extension supports this method (via is_callable, although 6.2.9 is pretty old now);
- Sets a default radius of 0 (auto-select);
- Sets a default sigma of 1 (or 0.5 for 0.25+ MP images);
- Changes from FILTER_TRIANGLE to FILTER_LANCZOS for 2.0+ MP images.
This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.
21 months ago
#7
@
21 months ago
- Keywords needs-patch needs-testing added
This ticket was discussed in the recent bug scrub.
The ticket need patch and manual testing.
Props to @costdev
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
21 months ago
#9
@
21 months ago
This should move to 6.3 whenever possible as the bandwidth of the Media team is not wide enough to take this on in 6.2. This is still desirable, just needs more time to bake when a patch is proposed.
This ticket was mentioned in Slack in #core-media by joedolson. View the logs.
18 months ago
#13
@
18 months ago
- Keywords close added
Imho this is a "plugin material".
Eventually may be relevant to core if the thumbnails in WP are "re-imagined". However currently the thumbnails are used only on the "List view" of the media library. Not sure how many users actually see that list view as the grid view is the default.
#14
@
18 months ago
Actually, a very common example is the small images used in WooCommerce product image galleries.
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
17 months ago
#16
@
17 months ago
- Milestone changed from 6.3 to Future Release
It was discussed in the recent Media component meeting that this is definitely a benefit to Core as a whole, but falls in the middle of plugin territory. It's great that EWWW and others support better quality thumbnails, and maybe that's a good value for these plugins to continue providing.
That's not to say this isn't desirable in a future release of WordPress but it isn't as high priority as other items in the 6.3 milestone. Going to move this to Future Release so we keep this discussion preserved for future work. Maybe this will be a higher demanded issue in the future. :)
Moving this to investigate for 6.2 alongside #56344