[wp-trac] [WordPress Trac] #59339: Conversion to webp causes fatal error when original image is a palette image (as opposed to truecolor)

WordPress Trac noreply at wordpress.org
Wed Sep 13 13:41:52 UTC 2023


#59339: Conversion to webp causes fatal error when original image is a palette
image (as opposed to truecolor)
----------------------------+-----------------------------
 Reporter:  jakeparis       |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Media           |    Version:  6.3.1
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 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
 <?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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59339>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list