Make WordPress Core

Opened 6 months ago

Last modified 5 weeks ago

#60291 new enhancement

Support Lossless WebP in WP_Image_Editor_GD

Reported by: adamsilverstein's profile adamsilverstein Owned by:
Milestone: 6.7 Priority: normal
Severity: normal Version: 5.8
Component: Media Keywords: has-patch needs-testing-info has-unit-tests
Focuses: Cc:

Description

While WordPress has supported WebP lossless since WebP support was introduced in WP 5.8 (https://make.wordpress.org/core/2021/06/07/wordpress-5-8-adds-webp-support/) - outputting lossless sub-size image when you upload a lossless WebP - this only worked correctly when Imagick was installed as at the time lossless was not supported in PHP's bundled GD.

PHP's bundled GD supports lossless output for WebP images since PHP 8.1, see see php.watch/versions/8.1/gd-webp-lossless.

The capability to handle lossless WebPs can be detected in GD by the presence of the IMG_WEBP_LOSSLESS constant.

To fix this - similar to Imagick, GD should output WebP lossless images when lossless WebP images are uploaded.

Change History (11)

This ticket was mentioned in PR #5891 on WordPress/wordpress-develop by @adamsilverstein.


6 months ago
#1

  • Keywords has-patch added; needs-patch removed

GD supports lossless output for WebP images since 8.1, see see https://php.watch/versions/8.1/gd-webp-lossless.

The capability can be detected by the presence of the IMG_WEBP_LOSSLESS constant.

Similar to Imagick, GD will now output WebP lossless images when lossless WebP images are uploaded.

Also similar to the Imagick implementation, this ignores the quality setting and favors the IMG_WEBP_LOSSLESS constant which must be available.

Trac ticket: https://core.trac.wordpress.org/ticket/60291

#2 @adamsilverstein
6 months ago

  • Keywords needs-testing-info needs-unit-tests added

I will work on adding a unit test to the PR next, then it should be ready to commit.

#3 @adamsilverstein
6 months ago

Testing Instructions

  • test on a server with PHP 8.1 with GD enabled (and no Imagick)
  • verify the IMG_WEBP_LOSSLESS constant is set
  • Try uploading a lossless WebP image
  • verify that generated images (eg. thumnail, medium, large) are also WebP lossless images

#4 @swissspidy
5 months ago

  • Milestone changed from Awaiting Review to 6.6

This ticket was mentioned in Slack in #core-performance by adamsilverstein. View the logs.


2 months ago

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


8 weeks ago

This ticket was mentioned in Slack in #core-test by martin.krcho. View the logs.


6 weeks ago

#10 @oglekler
5 weeks ago

  • Keywords has-unit-tests added; needs-unit-tests removed
  • Milestone changed from 6.6 to 6.7
  • Type changed from defect (bug) to enhancement

We have RC1 later today and...

This ticket needs testing and looks like an enhancement and not a bug fix. So, I am moving it to the next milestone and adjusting its type.

@adamsilverstein it still needs testing instructions. Can you provide them, please? 🙏

#11 @adamsilverstein
5 weeks ago

@oglekler - thanks for triaging I was away and didn’t get a chance to fully test this, but I did leave testing instructions above in comment number 3. I’ll will get this committed in 6.7 - still appreciate any testing/confirmation though!

Last edited 5 weeks ago by adamsilverstein (previous) (diff)
Note: See TracTickets for help on using tickets.