Make WordPress Core

Opened 3 years ago

Last modified 17 months ago

#55036 assigned enhancement

Sharpen thumbnails with Imagick adaptiveSharpenImage()

Reported by: galbaras's profile galbaras Owned by: antpb's profile 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

#2 @antpb
2 years ago

  • Milestone changed from Awaiting Review to 6.2

Moving this to investigate for 6.2 alongside #56344

#3 @galbaras
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 @craigfrancis
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):

This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.


21 months ago

#7 @mukesh27
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 @antpb
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.

#10 @sabernhardt
21 months ago

  • Milestone changed from 6.2 to 6.3

This ticket was mentioned in Slack in #core-media by joedolson. View the logs.


18 months ago

#12 @antpb
18 months ago

  • Owner set to antpb
  • Status changed from new to assigned

#13 @azaozz
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.

Version 0, edited 18 months ago by azaozz (next)

#14 @galbaras
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 @antpb
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. :)

Note: See TracTickets for help on using tickets.