Make WordPress Core

Opened 2 years ago

Last modified 6 months ago

#59339 new defect (bug)

Conversion to webp causes fatal error when original image is a palette image (as opposed to truecolor)

Reported by: jakeparis's profile jakeparis Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.3.1
Component: Media Keywords:
Focuses: administration Cc:

Description

I am working on an image conversion plugin. I've run into a bug when the original image is a "paletter image"https://www.thecoderscamp.com/paletter-image-not-supported-by-webp/", or in other words, an image that has an indexed palette rather than being truecolor. I believe it's a png.

The error I get is:

Fatal error: Paletter image not supported by webp in /home/username/public_html/wp-includes/class-wp-image-editor.php on line 584

And how I'm using it:

<?php
$image_editor = wp_get_image_editor( $this->image_path );
$new_file_info = $this->get_editor()->save( $this->image_path, 'image/webp' );

This method worked fine on hundreds of images of png, jpg, and tiff until I ran into this one that has a "palette".

In wp-includes/class-wp-image-editor-gd.php:487, if the image loaded into WP_Image_Editor is a png, we check for a palette and convert to true color before saving. I believe that we need to also check in the webp conditional and, just like for png, convert to truecolor first.

Change History (5)

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


21 months ago

#2 @adamsilverstein
21 months ago

Hi @jakeparis - thanks for the bug report.

Can you please attach the image that causes the error? Also, can you check Tools->site Health -> Info -> Media to see if your system is using Imagick or GD (and the version).

#4 @jakeparis
6 months ago

Sorry I never responded. I never was able to find the image that trigger the error because we were handling a bunch of images all at once. But here is the other information:

Media Handling
Active editor	                WP_Image_Editor_GD
ImageMagick version number	Not available
ImageMagick version string	Not available
Imagick version	                Not available
File uploads	                Enabled
Max size of post data allowed	50M
Max size of an uploaded file	50M
Max effective file size	        50 MB
Max simultaneous file uploads	20
GD version	                bundled (2.1.0 compatible)
GD supported file formats	GIF, JPEG, PNG, WebP, BMP
Ghostscript version	        9.25

Version 0, edited 6 months ago by jakeparis (next)
Note: See TracTickets for help on using tickets.