Ticket #24380: 24380.3.patch
File 24380.3.patch, 2.2 KB (added by , 10 years ago) |
---|
-
wp-includes/class-wp-image-editor-gd.php
383 383 if ( function_exists('imageistruecolor') && ! imageistruecolor( $image ) ) 384 384 imagetruecolortopalette( $image, false, imagecolorstotal( $image ) ); 385 385 386 if ( ! $this->make_image( $filename, 'imagepng', array( $image, $filename ) ) ) 386 /* 387 * Convert quality (1-100) to a valid compression value (0-9) 388 * -1 = use default zlib compression 389 * 0 = no compression 390 * 1 = worst compression 391 * 9 = best compression 392 */ 393 $compression_level = floor( $this->quality / 10 ); 394 395 if ( $compression_level > 9 ) { 396 $compression_level = 9; 397 } elseif ( -1 != $compression_level && $compression_level < 0 ) { 398 $compression_level = 0; 399 } 400 if ( ! $this->make_image( $filename, 'imagepng', array( $image, $filename, $compression_level ) ) ) { 387 401 return new WP_Error( 'image_save_error', __('Image Editor Save Failed') ); 402 } 388 403 } 389 404 elseif ( 'image/jpeg' == $mime_type ) { 390 405 if ( ! $this->make_image( $filename, 'imagejpeg', array( $image, $filename, $this->quality ) ) ) -
wp-includes/class-wp-image-editor.php
244 244 if ( $quality == 0 ) { 245 245 $quality = 1; 246 246 } 247 } elseif ( 'image/png' == $this->mime_type ) { 248 /** 249 * Filter the PNG compression level. 250 * 251 * The filter is evaluated under two contexts: 'image_resize', and 'edit_image', 252 * (when a PNG image is saved to file). 253 * 254 * @since 4.0.0 255 * 256 * @param int $quality Compression level, between 1 (worst compression) 257 * and 100 (best but slowest compression). 258 * @param string $context Context of the filter. 259 */ 260 $quality = apply_filters( 'png_compression_level', $quality, 'image_resize' ); 247 261 } 248 262 249 263 if ( ( $quality >= 1 ) && ( $quality <= 100 ) ){