Make WordPress Core

Opened 10 months ago

Closed 6 weeks ago

Last modified 6 weeks ago

#60291 closed enhancement (fixed)

Support Lossless WebP in WP_Image_Editor_GD

Reported by: adamsilverstein's profile adamsilverstein Owned by: adamsilverstein's profile adamsilverstein
Milestone: 6.7 Priority: normal
Severity: normal Version: 5.8
Component: Media Keywords: has-patch has-unit-tests commit
Focuses: performance 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 (19)

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


10 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
9 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
9 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
9 months ago

  • Milestone changed from Awaiting Review to 6.6

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


6 months ago

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


5 months ago

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


5 months ago

#10 @oglekler
5 months 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 months 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 months ago by adamsilverstein (previous) (diff)

#12 @desrosj
6 weeks ago

@adamsilverstein do you still plan to get this committed for 6.7? There's roughly 24 hours until the beta 1 cut off.

#13 @adamsilverstein
6 weeks ago

@adamsilverstein do you still plan to get this committed for 6.7? There's roughly 24 hours until the beta 1 cut off.

Thanks for the ping @desrosj - I'll get this committed today.

#14 @adamsilverstein
6 weeks ago

  • Focuses performance added

#15 @adamsilverstein
6 weeks ago

  • Keywords commit added; needs-testing-info removed

#16 @davidbaumwald
6 weeks ago

  • Owner set to adamsilverstein
  • Status changed from new to reviewing

#17 @adamsilverstein
6 weeks ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 59136:

Media: improve support for lossless WebP.

When uploading lossless WebP images, WordPress now correctly outputs lossless WebP with both the Imagick and GD image editors.

Props: adamsilverstein, martinkrcho.
Fixes #60291.

@adamsilverstein commented on PR #5891:


6 weeks ago
#18

Merged

#19 @adamsilverstein
6 weeks ago

In 59145:

Media: improve support for lossless WebP.

When uploading lossless WebP images, WordPress now correctly outputs lossless WebP with both the Imagick and GD image editors.

Props: adamsilverstein, martinkrcho.
Fixes #60291.

Note: See TracTickets for help on using tickets.