简体   繁体   English

在上传之前防止wordpress影响图像质量

[英]Prevent wordpress from compromising image quality before uploading

Wordpress keeps applying some kind of compression during uploads to my images thereby compromising with the quality. Wordpress在上传到我的图片期间不断应用某种压缩,从而影响质量。 Where do i deactivate this functionality. 我在哪里停用此功能。 I have already tried .. 我已经试过..

function add_image_size( $name, $width = 0, $height = 0, $crop = false ) 

but hasnt helped so far. 但到目前为止还没有帮助。 Also tried 也试过了

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

but both havent helped so far. 但到目前为止两者都没有帮助。 Any ideas ?? 有任何想法吗 ??

I had the same issue with images on my WordPress site being compressed to the point that the jpeg artifacts made most of my images unusable (I'm a photographer, so I can't deal with artifacts like most WordPress users probably can). 我的WordPress网站上的图像被压缩到jpeg工件使我的大部分图像无法使用(我是一名摄影师,所以我无法像大多数WordPress用户那样处理工件)。 What ended up doing the trick for me was disabling the "Image Performance" option in Jetpack from the Admin Dashboard (meaning, WordPress wasn't compressing my images on upload, per se, but the end effect was the same). 最后为我做的技巧是从Admin Dashboard中禁用Jetpack中的“图像性能”选项(意思是,WordPress本身并没有在上传时压缩我的图像,但最终效果是相同的)。 Here's a screenshot: 这是一个截图:

From what I understand, this option speeds up the load times of your images in two ways; 据我了解,此选项以两种方式加快图像的加载时间; A) it hosts them on a cloud of servers that allow images to be served closer to the clients that request them and B) it uses lossy compression to drastically reduce file sizes. A)它将它们托管在服务器云上,允许图像更靠近请求它们的客户端,B)它使用有损压缩来大幅减少文件大小。

On my site, I host a gallery of thumbnail images which link to high-res versions. 在我的网站上,我主持了一个链接到高分辨率版本的缩略图图库。 With the "Image Performance" option turned on, notice how the image is hosted by a different server altogether and that there are lots of compression artifacts in it, especially in the sky gradients of the image. 打开“图像性能”选项后,请注意图像是如何由不同的服务器共同承载的,并且其中存在大量压缩工件,尤其是在图像的天空渐变中。

After turning "Image Performance" off, the full-size image is now served directly by my hosting service and the compression artifacts are gone. 关闭“图像性能”后,我的托管服务现在直接提供全尺寸图像,压缩工件消失了。

Additional Thoughts 额外的想法

For my particular case, WordPress wasn't actually compressing the original uploaded images, it was re-uploading them to the servers that Jetpack uses when you have the "Image Performance" option turned on, where they were then further compressed. 对于我的特定情况,WordPress实际上并没有压缩原始上传的图像,而是在打开“图像性能”选项时将它们重新上传到Jetpack使用的服务器,然后进一步压缩它们。 This may not be exactly what's happening in the OP's case, but because I initially assumed WordPress was compressing my images on upload as well, I believe this answer is relevant to the question. 这可能不完全是OP的情况,但是因为我最初假设WordPress也在上传时压缩我的图像,我相信这个答案与这个问题有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM