简体   繁体   English

为了获得最佳效果,您是否应该重新调整图像大小然后对其进行压缩,还是应该对其进行压缩然后重新调整大小?

[英]For best results, should you re-size an image and then compress it or should you compress it and then re-size it?

I'm trying to cut down on a picture size and I was wondering: 我正试图减少图片大小,我想知道:

Is it better to compress the original image first, then re-size it or should I re-size it and then compress the smaller version of it? 最好先压缩原始图像,然后重新调整它的大小,还是应该重新调整它的大小,然后压缩它的较小版本?

Is there any difference? 有什么区别吗?

I'm working with C#. 我正在使用C#。

压缩会导致图像质量和细节丢失,因此一般来说,应用后应始终是应用任何修改后的最后一步。

No matter what you do, compression always happens last. 无论你做什么,压缩总是最后发生。 This is because compression is inherent in the saving of the image, and it is impractical to try to work with the image in its compressed form; 这是因为压缩是保存图像所固有的,尝试以压缩形式处理图像是不切实际的。 you virtually always uncompress it in order to work with the image itself, and not simply pass the file around. 你几乎总是解压缩它以便使用图像本身,而不是简单地传递文件。

So, if you compress, then resize, the sequence of steps is compress->uncompress->resize->compress. 因此,如果您压缩,然后调整大小,则步骤序列为compress-> uncompress-> resize-> compress。 If you are using a "lossless" compressed image format, like PNG, you're wasting time on the initial two steps because nothing will change, and you might as well just resize, then compress. 如果你使用的是“无损”压缩图像格式,比如PNG,你就会在最初的两个步骤上浪费时间,因为什么都不会改变,你可能只是调整大小,然后压缩。

Where this might have a difference is when using "lossy" compression algorithms like JPEG. 可能有所不同的地方在于使用像JPEG这样的“有损”压缩算法。 "Lossy" formats use similar algorithms to actually compress the data of the image as lossless ones, but they incorporate an additional step of simplification; “有损”格式使用类似的算法来实际压缩图像数据作为无损图像,但它们包含额外的简化步骤; the image is processed to produce (hopefully) subtle changes in the actual pixels, which allows the entire image to be digested more efficiently by the compression algorithm (usually, blocks of pixels are made more similar, so that the entire block can be represented by one or two bytes of "hash" which is then cross-referenced in a metadata dictionary and the hash substituted for the block where it occurs). 处理图像以产生(希望)实际像素的细微变化,这允许通过压缩算法更有效地消化整个图像(通常,像素块更加相似,因此整个块可以由一个或两个字节的“哈希”,然后在元数据字典中交叉引用,并且哈希替换它出现的块)。 This simplification is one-way; 这种简化是单向的; you can't "un-simplify" the processed image to get the original one back, and so the sequence of steps for a compress and then resize is simplify->compress->uncompress->resize->simplify->compress. 你不能“简化”处理后的图像以获得原始图像,因此压缩然后调整大小的步骤顺序是简化 - >压缩 - >解压缩 - >调整大小 - >简化 - >压缩。 The simplification step happens twice, affecting the image before and after resizing. 简化步骤发生两次,影响调整大小之前和之后的图像。 Whether this actually results in a smaller file size depends on the exact image and the quality settings used to apply the simplification filter. 这实际上是否会导致较小的文件大小取决于用于应用简化过滤器的确切图像和质量设置。

if you resize image before compress it is better for quality of image but bad for streaming because or data size 如果你在压缩之前调整图像大小,那么图像质量会更好,但是因为数据大小而不适合流式传输

if you compress and resize it is better for streaming (small size) but quality will be limited at original size 如果你压缩和调整大小,最好是流媒体(小尺寸),但质量将限制在原始大小

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

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