WordPress.org

Make WordPress Core

Ticket #24380: 24380.2.diff

File 24380.2.diff, 1.1 KB (added by ericlewis, 6 years ago)
  • src/wp-includes/class-wp-image-editor-gd.php

    diff --git a/src/wp-includes/class-wp-image-editor-gd.php b/src/wp-includes/class-wp-image-editor-gd.php
    index 303f500..8c003e7 100644
    a b class WP_Image_Editor_GD extends WP_Image_Editor { 
    383383                        if ( function_exists('imageistruecolor') && ! imageistruecolor( $image ) )
    384384                                imagetruecolortopalette( $image, false, imagecolorstotal( $image ) );
    385385
    386                         if ( ! $this->make_image( $filename, 'imagepng', array( $image, $filename ) ) )
     386                        // Invert the 1-100 quality scale and constrain it to 0-9,
     387                        // as per imagepng()'s peculiar quality parameter.
     388                        $compression_level = floor( ( 101 - $this->quality ) * 0.09 );
     389
     390                        if ( ! $this->make_image( $filename, 'imagepng', array( $image, $filename, $compression_level ) ) ) {
    387391                                return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
     392                        }
    388393                }
    389394                elseif ( 'image/jpeg' == $mime_type ) {
    390395                        if ( ! $this->make_image( $filename, 'imagejpeg', array( $image, $filename, $this->quality ) ) )