admin管理员组

文章数量:1122832

I'm having issues with images getting badly compressed when uploaded to my site. It's not an issue with photographs, but is very noticeable for images with solid blocks of colour and text.

I've uploaded a PNG with a solid grey background overlaid with white text, and it's being badly compressed when WordPress resizes it to the various alternative sizes.

Original image

Large featured image size

Unfortunately I don't have enough reputation to post more than 2 links, but you can see in the resized Large version that the text has become very blurry, and the solid grey background has a noticeable strobe to it.

I know you can turn off / adjust the level of JPG image compression, but as far as I know WordPress shouldn't be compressing PNGs at all, so I'm at a loss to figure out what's going on.

What could be causing this? Is this potentially an issue with the compression / resize software on my server? Or is there a way to tell WordPress not to compress PNGs, like there is with JPEGs?

I'm having issues with images getting badly compressed when uploaded to my site. It's not an issue with photographs, but is very noticeable for images with solid blocks of colour and text.

I've uploaded a PNG with a solid grey background overlaid with white text, and it's being badly compressed when WordPress resizes it to the various alternative sizes.

Original image

Large featured image size

Unfortunately I don't have enough reputation to post more than 2 links, but you can see in the resized Large version that the text has become very blurry, and the solid grey background has a noticeable strobe to it.

I know you can turn off / adjust the level of JPG image compression, but as far as I know WordPress shouldn't be compressing PNGs at all, so I'm at a loss to figure out what's going on.

What could be causing this? Is this potentially an issue with the compression / resize software on my server? Or is there a way to tell WordPress not to compress PNGs, like there is with JPEGs?

Share Improve this question edited May 18, 2016 at 9:57 Chris Jenkins asked May 18, 2016 at 9:30 Chris JenkinsChris Jenkins 114 bronze badges 3
  • You say you uploaded a PNG, but the referenced original image is a JPG? – TheDeadMedic Commented May 18, 2016 at 9:36
  • Very good point, I've linked to a test by mistake. I'll edit the original question now! – Chris Jenkins Commented May 18, 2016 at 9:40
  • Hmm, yep, can definitely see the artifact. Trouble is I think this is beyond WordPress - it's more likely an ImageMagick/GD issue (PHP image libraries). Might be worth looking for a public resizing API - if you can find one that gives you the results you're after, a new question "how to integrate service X into WordPress resizing process" would be a worthy candidate. – TheDeadMedic Commented May 18, 2016 at 11:13
Add a comment  | 

2 Answers 2

Reset to default 1

This probably has to do with the ImageMagick library that WP normally uses to resize images. I'm not sure whether it is possible to modify the standard settings WP applies, but it is possible to define your own. Here is a tutorial for that. You would have to replace the filter in that tutorial with one of your own using ImageMagick's interface. But that's a lot of work.

You must set the compression rate higher. i think this will be help you.

Since the Wordpress Version 4.5 is the compression rate 82% - before 90%

add this to your functions.php

add_filter('jpeg_quality', function($arg){
    return 100;
});

本文标签: imagesWordPress PNG compression issue