1

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#.

JJ.
  • 9,580
  • 37
  • 116
  • 189

3 Answers3

3

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. 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.

Where this might have a difference is when using "lossy" compression algorithms like 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.

KeithS
  • 70,210
  • 21
  • 112
  • 164
2

Compression causes loss of quality and details in your image, so as a general rule it should always be the last step after applying any modifications.

DeveloperInToronto
  • 1,173
  • 2
  • 14
  • 32
  • 1
    ... Except that resizing also causes loss of quality/detail. What's more important in requiring compression to be last is that, while compressed, the image is effectively immutable; you have to uncompress it to change it, and then recompress it (which hopefully will result in the same lossy simplifications that are performed prior to actual compression not having an effect). – KeithS Aug 17 '12 at 20:42
0

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

Hassan Boutougha
  • 3,871
  • 1
  • 17
  • 17