WordPress.org

Make WordPress Core

Ticket #24380: 24380.3.diff

File 24380.3.diff, 1.1 KB (added by ericlewis, 5 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..a720066 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                        /*
     387                         * Invert the 1-100 quality scale and constrain it to 0-9,
     388                         * as per imagepng()'s peculiar quality parameter.
     389                         */
     390                        $compression_level = floor( ( 101 - $this->quality ) * 0.09 );
     391
     392                        if ( ! $this->make_image( $filename, 'imagepng', array( $image, $filename, $compression_level ) ) ) {
    387393                                return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
     394                        }
    388395                }
    389396                elseif ( 'image/jpeg' == $mime_type ) {
    390397                        if ( ! $this->make_image( $filename, 'imagejpeg', array( $image, $filename, $this->quality ) ) )