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' );
  • Does your Mac laptop have a retina display? – K Themes Oct 22 '14 at 7:36
  • @K No I don't think it has retina display. It is NOT a MacBookPRO. It's a Mac 13 inch , OS X version 10.5.8 , LED-backlit screen , 32-BIT color , resolution 1280 x 800 --- But other websites seem to have crisp images. And my original 400x400 px thumbnails are fine, it is the compressed images that contain the "gray pixels on white background" problem. Any tips? – leko Oct 22 '14 at 8:28
  • To help you and others building a test case: The problem is "compression artifacts". Probably only when (a) the resulting quality isn't 100%, (b) the original quality isn't 100% or (c) you are resizing to a size not multiple times the original size (anti aliasing problems). – kaiser Dec 8 '14 at 17:04

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

  • Please explain why this answer is helpful. So far this is an assumption. – kaiser Dec 4 '14 at 16:32
  • 1
    @kaiser I've had the exact same problem and I'm pretty sure this was it. I've done a test with a blank wordpress install with and without ImageMagick and was able to reproduce the problem and solve it. (p.s. I think the downvote was a bit harse since this was a topic that was not going to be solved otherwise.) – adnan Dec 8 '14 at 9:09
  • Well, do you have an image that can reproduce the problem? I'd happily give it a test. So far this still is no answer and it does not explain why this would happen. There must be specifics that can get narrowed down and then finally ImageMagick would at fault and you should file a bug report at their repos. As long as there is nothing that explains why this happens, it stays: Your answer is an assumption and I likely will have to remove it later on. Please take your time, do some research. – kaiser Dec 8 '14 at 13:48
  • Hi Kaiser, thanks for your reply. A blank wordpress install without ImageMagick and any blank JPG will produce the error. I've talked about this on the wordpress IRC, but since it's not wordpress related I can't file a bug report on the wordpress repo. It's probably GD related, but I'm not so sure about that. – adnan Dec 8 '14 at 15:59
  • With blank JPG I meant white JPG image. – adnan Dec 9 '14 at 8:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.