id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,focuses
24380,Missing Compression Parameter in WP_Image_Editor_GD,MuViMoTV,wonderboymusic,"Setting the image quality parameter has no effect on png files.
Going through the wp-includes/class-wp-image-editor-gd.php
I noticed that the compression parameter for the imagepng function call is missing.
the current quality parameter only affects jpeg files.
for jpeg, quality goes from 0->100 from bad to good
for png, from 0->9 from good to bad.
in the elseif block starting at line 337 i have added a variable called compression and changed the code as follow:
{{{
elseif ( 'image/png' == $mime_type ) {
// convert from full colors to index colors, like original PNG.
if ( function_exists('imageistruecolor') && ! imageistruecolor( $image ) )
imagetruecolortopalette( $image, false, imagecolorstotal( $image ) );
$compression = -((9/100*$this->quality)-9);
if ( ! $this->make_image( $filename, 'imagepng', array( $image, $filename, $compression ) ) )
return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
}
}}}
This convert the scale 0->100 into a 0->9 scale that matches the parameters from imaging.
This gives back control to the user on image quality for png files...",enhancement,reopened,normal,Future Release,Media,3.5.1,normal,,has-patch dev-feedback needs-refresh,,