简体   繁体   English

压缩图像,有一点吗?

[英]Compressing images, is there a point?

I'm working on a web site which will host thousands of user uploaded images in the formats, .png, .jpeg, and .gif. 我正在一个网站上工作,该网站将以.png,.jpeg和.gif格式托管数千个用户上传的图像。

Since there will be such a huge amount of images, saving just a few kb of space per file will in the end mean quite a lot on total storage requirements. 由于将有如此大量的图像,因此每个文件仅节省几kb的空间将最终意味着大量的总存储需求。

My first thought was to enable windows folder compression on the folder that the files are stored in (using a Windows / IIS server). 我的第一个想法是在文件存储所在的文件夹中启用Windows文件夹压缩(使用Windows / IIS服务器)。 On a total of 1Gb of data the total space saved on this was ~200kb. 在总共1Gb的数据上,节省的总空间约为200kb。

This to me seems like a poor result. 在我看来,这似乎是一个糟糕的结果。 I therefore went to check if the windows folder compression could be tweaked but according to this post it cant be: NTFS compressed folders 因此,我去检查Windows文件夹压缩是否可以调整,但是根据这篇文章,它不能是: NTFS压缩文件夹

My next though was then that I could use libraries such as Seven Zip Sharp to compress the files individually as I save them. 但是,接下来我要使用的文件库是“ Seven Zip Sharp”之类的文件,以便在保存文件时分别对其进行压缩。 But before I did this I went to test a few different compression programs on a few images. 但是在我这样做之前,我先在一些图像上测试了一些不同的压缩程序。

The results on a 7Mb .gif was that 在7Mb .gif上的结果是

7z, Compress to .z7 = 1kb space saved  
7z, Compress to .zip = 2kb space INCREASE  
windows, native zip = 4kb space saved.

So this leaves me with two thoughs.. the zipping programs I'm using aren't very good, or images are pretty much already compressed as far as they can be (..and I'm surprised that windows built in compression is better than 7z). 所以这给了我两个建议。.我使用的压缩程序不是很好,或者图像已经尽可能地被压缩了(..我很惊讶内置压缩的Windows更好比7z)。

So my question is, is there any way to decrease the filesize of an image archive consisting of the image formats listed above? 所以我的问题是,有什么办法可以减少由上述图像格式组成的图像档案的文件大小?

the zipping programs I'm using suck, or images are pretty much already compressed as far as they can be 我正在使用的ZIP压缩程序,或者图像已经尽可能地被压缩

Most common image formats are already compressed (PNG, JPEG, etc). 大多数常见的图像格式已经被压缩(PNG,JPEG等)。 Compressing a file twice will almost never yield any positive result, most likely it will only increase the file size. 两次压缩文件几乎不会产生任何积极效果,很有可能只会增加文件大小。

So my question is, is there any way to decrease the filesize of an image archive consisting of the image formats listed above? 所以我的问题是,有什么办法可以减少由上述图像格式组成的图像档案的文件大小?

No, not likely. 不,不太可能。 Compressed files might have at most a little more to give, but you have specialize on images itself, not the compression algoritm. 压缩文件最多可以提供更多,但是您只专注于图像本身,而不是压缩算法。 Some good options are available in the post of Robert Levy . Robert Levy的帖子中提供了一些不错的选择。 A tool I used to strip out metadata is PNGOUT . 我用来剥离元数据的工具是PNGOUT

Most users will likely be uploading files that have a basic level of compression already done on them so that's why you aren't seeing a ton of benefit. 大多数用户可能会上传已对文件进行了基本压缩的文件,因此这就是为什么您没有看到很多好处的原因。 Some users may be uploading uncompressed files though in which case your attempts would make a difference. 有些用户可能正在上传未压缩的文件,但是在这种情况下,您的尝试会有所作为。

That said, image compression should be thought of as a unique field from normal file compression. 也就是说,应该将图像压缩视为普通文件压缩中的唯一字段。 Normal file compression techniques will be "lossless", ensuring that every bit of the file is restored when the file is uncompressed - images (and other media) can be compressed in "lossy" ways without degrading the file to an unacceptable level. 普通的文件压缩技术将是“无损的”,可确保在文件未压缩时恢复文件的每一位-可以以“有损”的方式压缩图像(和其他媒体),而不会降低文件的质量。

There are specialized tools such which you can use to do things like strip out metadata, apply a slight blur, perform sampling, reduce quality, reduce dimensions, etc. Have a look at the answer here for a good example: Recommendation for compressing JPG files with ImageMagick . 有专门的工具,您可以用来做一些事情,例如删除元数据,应用轻微的模糊,执行采样,降低质量,缩小尺寸等。在这里查看一个很好的例子的答案: 压缩JPG文件的建议使用ImageMagick The top answer took the example file from 264kb to 170kb. 最重要的答案是将示例文件从264kb扩展到170kb。

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

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