Make WordPress Core


Ignore:
Timestamp:
05/30/2014 08:05:02 PM (11 years ago)
Author:
wonderboymusic
Message:

In WP_Image_Editor_GD::_save(), pass $compression_level into the args array for ->make_image().

Props MuViMoTV, markoheijnen, SergeyBiryukov, mikemanger, ericlewis.
Fixes #24380.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-image-editor-gd.php

    r28513 r28640  
    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 ) {
Note: See TracChangeset for help on using the changeset viewer.