[wp-trac] [WordPress Trac] #63773: Palette-based PNG cause failure attempting AVIF/WebP conversion under GD

WordPress Trac noreply at wordpress.org
Fri Jan 23 14:05:22 UTC 2026


#63773: Palette-based PNG cause failure attempting AVIF/WebP conversion under GD
-------------------------------------------------+-------------------------
 Reporter:  adamsilverstein                      |       Owner:
                                                 |  adamsilverstein
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Media                                |     Version:  5.8
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests dev-        |     Focuses:
  reviewed has-screenshots has-test-info         |
-------------------------------------------------+-------------------------
Changes (by ozgursar):

 * keywords:  has-patch has-unit-tests dev-reviewed needs-testing => has-
     patch has-unit-tests dev-reviewed has-screenshots has-test-info


Comment:

 == Patch Testing Report

 Patch Tested: https://github.com/WordPress/wordpress-develop/pull/9368

 === Environment
 - WordPress: 7.0-alpha-61215-src
 - PHP: 8.2.29
 - Server: nginx/1.29.4
 - Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
 - Browser: Chrome 144.0.0.0
 - OS: macOS
 - Theme: Twenty Twenty-One 2.7
 - MU Plugins: None activated
 - Plugins:
   * Code Snippets 3.9.4
   * Test Reports 1.2.1

 === Steps taken
 1. Download the sample image from PR
 [https://raw.githubusercontent.com/WordPress/wordpress-
 develop/6e5d64ef20c75f464632f1c7c4fb92bf60d55a36/tests/phpunit/data/images
 /png-tests/dice-palette.png]
 2. In order to use GD and confirm it via admin notices add the following
 code via Code Snippets or functions.php


 {{{
 add_filter('wp_image_editors', function($editors) {
     return array('WP_Image_Editor_GD');
 });

 add_action('admin_notices', function() {
     $implementations = _wp_image_editor_choose(array('mime_type' =>
 'image/png'));
     echo '<div class="notice notice-info"><p>';
     echo 'Image Editor: ' . (!is_wp_error($implementations) &&
 !empty($implementations) ? $implementations : 'Error or none found');
     echo '</p></div>';
 });

 add_filter('image_editor_output_format', function($formats) {
     $formats['image/png'] = 'image/webp';
     return $formats;
 });
 }}}

 3. You should now see `Image Editor: WP_Image_Editor_GD` at the admin
 notices section.
 4. Media > Add Media File > Upload the sample dice-palette.png
 5. ❌ Bug occurs. Generated webp image is zero file size.
 6. The following error is added to log.
 [DATETIME] PHP Warning:  imagewebp(): Palette image not supported by webp
 in /var/www/src/wp-includes/class-wp-image-editor.php on line 577
 7. Manually check the wp-content/uploads to confirm the filesize to be
 zero.
 8. Apply patch.
 9. Reupload the dice-palette.png sample image.
 10. Image properly gets uploaded, no error is logged.
 11. ✅ Patch is solving the problem.

 === Expected result
 - Patch works as expected. GD library can properly convert a palette based
 PNG image to webp.

 === Screenshots/Screencast with results
 Media before applying patch:
 [[Image(https://i.imgur.com/G9QocLu.png)]]

 Filesize before applying patch:
 [[Image(https://i.imgur.com/iVuQajZ.png)]]

 ----


 Media after applying patch:
 [[Image(https://i.imgur.com/WJutBpc.png)]]

 Filesize after applying patch:
 [[Image(https://i.imgur.com/q0tbbEV.png)]]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63773#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list