Make WordPress Core

Opened 6 weeks ago

Last modified 8 days ago

#60291 new defect (bug)

Support Lossless WebP in WP_Image_Editor_GD

Reported by: adamsilverstein's profile adamsilverstein Owned by:
Milestone: 6.6 Priority: normal
Severity: normal Version: 5.8
Component: Media Keywords: has-patch needs-testing-info needs-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 (4)

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


6 weeks 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
3 weeks 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
3 weeks 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
8 days ago

  • Milestone changed from Awaiting Review to 6.6
Note: See TracTickets for help on using tickets.