Make WordPress Core

Opened 3 weeks ago

Closed 4 days ago

#65922 closed defect (bug) (fixed)

regression: client-side processing creates thumbnails larger than original for indexed PNG images

Reported by: nosilver4u Owned by: adamsilverstein
Priority: normal Milestone: 7.1.1
Component: Media Version: 7.1
Severity: normal Keywords: has-unit-tests has-patch
Cc: Focuses: performance

Description

When uploading an indexed PNG image in WP 7.1, we found that all of the thumbnails are saved with an RGBA color type instead of indexed/palette. As discussed in #36477, this causes the thumbnail to have much larger sizes than they ought to, and often larger than the original.
For example, in the image I've attached, the original is 200kb, but a 1024px (large) version is 216kb, while the 1536px version is a whopping 444kb. This is in contrast to thumbs generated with ImageMagick, where the large version is 70kb and the 1536 is only 111kb.

Attachments (1)

rabbit-time-paletted-or8.png (195.9 KB ) - added by nosilver4u 3 weeks ago.
indexed PNG image

Download all attachments as: .zip

Change History (13)

@nosilver4u
3 weeks ago

indexed PNG image

#1 @westonruter
3 weeks ago

  • Owner set to adamsilverstein
  • Status newreviewing

#2 @adamsilverstein
3 weeks ago

Thanks for the bug report @nosilver4u - I'll take a look.

#4 @adamsilverstein
3 weeks ago

Thanks @siliconforks

#6 @adamsilverstein
3 weeks ago

  • Keywords has-unit-tests has-patch needs-testing added
  • Milestone Awaiting Review7.1.1
  • Status reviewingaccepted

Reproduced with the attached image. The palette chunk is reason: libvips decodes an indexed PNG into full RGB(A) pixels, and nothing in the client-side pipeline was asking pngsave to quantise back down, so every sub-size got written as truecolour.

libvips does flag the source encoding - a PNG loaded from an indexed original carries a palette metadata field - so the fix is to check that and pass palette: true on save. Gated on the source, so a truecolour PNG is never quantised.

The PR also includes some e2e tests.

@nosilver4u / @siliconforks can you give that a test?

in the meantime if this is causing an issue for you, use media library uploads (which still use the server processing) or install my disable-client-side-media plugin (from wordpress.org).

#7 @nosilver4u
3 weeks ago

Tested and confirmed working, thanks @adamsilverstein !

#8 @adamsilverstein
3 weeks ago

  • Keywords needs-testing removed

#9 @adamsilverstein
3 weeks ago

Thanks for testing @nosilver4u - I'm fine tuning the approach in the PR based on feedback and will plan to have this be part of the next point release.

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


4 days ago

#12 @adamsilverstein
4 days ago

  • Resolutionfixed
  • Status acceptedclosed

This will get fixed in core for 7.1.1, it is included in the list of backport being included: https://github.com/WordPress/gutenberg/pull/82383

Closing this one for now, feel free to re-open if it isn't resolved in 7.1.1.

Note: See TracTickets for help on using tickets.