Maintaining image color and quality when uploading using custom sizes

Use the jpeg_quality and wp_editor_set_quality filters to set the quality of resized images:

add_filter( 'wp_editor_set_quality', 'wpse246186_image_quality' );
add_filter( 'jpeg_quality', 'wpse246186_image_quality' );
function wpse246186_image_quality( $quality ) {
    return 100; // 0 - 100% quality
}

I have not been able to reproduce the issue reported; the original PNG image looks the same as the thumbnails. Tested in Chrome on Windows 7, PHP Version 5.6.19, GD Support: enabled, ImageMagick not installed, wide gamut hardware-calibrated monitor.

Notes

  • Make sure that images have been saved in the sRGB Color Space prior to uploading them to WordPress. This will prevent color and saturation loss.

  • Changing the quality setting will not affect images that have already
    been uploaded. Use a plugin such as Regenerate
    Thumbnails
    to
    update images that have already been uploaded.

  • The default quality setting is 82 in WordPress v4.5 onward.

Leave a Comment