performance icon indicating copy to clipboard operation
performance copied to clipboard

Transparent .pngs with colour type Palette cannot be converted

Open benniledl opened this issue 9 months ago • 3 comments

Bug Description

When uploading images, with the color type "Palette" or "PaletteAlpha", the plugin generates the full size-webp versions as an empty files (0 bytes). The resized versions are converted correctly. This results in images not being displayed to site visitors, as the .webp file is invalid.

Steps to Reproduce

Upload an image with the color type "Palette" or "PaletteAlpha" to the WordPress media library.
Navigate to the directory where the image is stored (e.g., /wp-content/uploads/2025/02/).
Observe that the corresponding .webp version of the image has a file size of 0 bytes.
As a result, the image is not displayed to site visitors.

Additional Notes

Converting the image to a different color type to sRGB before uploading resolves the issue for me.

Example

-rw-r--r-- 1 someuser someuser   858 2025-02-07 08:18 image-name-150x150.webp
-rw-r--r-- 1 someuser someuser 25160 2025-02-07 08:18 image-name-1536x864.webp
-rw-r--r-- 1 someuser someuser  2052 2025-02-07 08:18 image-name-300x169.webp
-rw-r--r-- 1 someuser someuser  9086 2025-02-07 08:18 image-name-768x432.webp
-rw-r--r-- 1 someuser someuser 33812 2025-02-07 08:18 image-name.png
-rw-r--r-- 1 someuser someuser     0 2025-02-07 08:18 image-name-png.webp

benniledl avatar Feb 11 '25 09:02 benniledl

Could you please share details about your PHP and GD/ImageMagick versions? That will help others trying to reproduce this.

swissspidy avatar Feb 11 '25 11:02 swissspidy

Actually, looks like a possible duplicate of #1561

swissspidy avatar Feb 11 '25 11:02 swissspidy

PHP Version 8.2.27 GD Version | bundled (2.1.0 compatible) Imagick 3.7.0

Neither GD or Imagick work

benniledl avatar Feb 11 '25 11:02 benniledl

@benniledl - can you check if the patch in https://github.com/WordPress/performance/pull/2024 fixes your issue?

adamsilverstein avatar Jul 19 '25 01:07 adamsilverstein

@benniledl I prepared a ZIP build of the plugin you can use to install via WP Admin > Plugins > Add Plugins > Upload Plugin.

westonruter avatar Aug 15 '25 23:08 westonruter