Thumbnails produce unwanted gray pixels on white background [closed]

Is there a workaround for producing QUALITY “Featured Image” thumbnails of different sizes?

WordPress produces compressed thumbnails that contain grey pixels where it should be a completely white background. Non-white backgrounds look okay. I am using Mac laptop if it matters. I am not using any plugins.

How can I stop WordPress compression from producing gray pixels on white backgrounds? The only plan I can think of is to go into uploads folder and manually erase the gray pixels with Paintbrush in Mac, but that will take forever. There must be an easier way??

Here’s the scenario. I upload one jpeg image as a “Featured Image” to display for index.php (240x240 px) and single.php (400x400 px)

In dashboard > Settings > Media I set up:

Large Size: 400x400 px
Medium Size: 240x240 px

I call the image like this:

<?php the_post_thumbnail( 'medium' ); ?>
<?php the_post_thumbnail( 'large' ); ?>

I tried using the below code in functions.php but the compressed thumbnail still produces gray pixels on white background.

function alx_thumbnail_quality( $quality ) {
    return 100;
}
add_filter( 'jpeg_quality', 'alx_thumbnail_quality' );
add_filter( 'wp_editor_set_quality', 'alx_thumbnail_quality' );

1 Answer
1

You are probably missing ImageMagick (PHP extension). Install it and the JPG artifacts will be gone.

Leave a Comment