Most image formats are already compressed. But in fact, if I take an image and compress it (gzipping it), and then I compare the compressed one to the uncompressed one, there is a difference in size, even though not such a dramatic difference.

The question is: is it worth gzipping images? the content size flushed down to the client's browser will be smaller, but there will be some client overhead when de-gzipping it.

  • 2
    If your server bottleneck is closer on network than on CPU, sure. Else, there might be lower hanging fruit.
    – Konerak
    Jan 27, 2011 at 20:18

3 Answers 3


Google makes reference to gzip and image/binary files at Minimize payload size

Don't use gzip for image or other binary files.

Image file formats supported by the web, as well as videos, PDFs and other binary formats, are already compressed; using gzip on them won't provide any additional benefit, and can actually make them larger. To compress images, see Optimize images.

  • 1
    favicon.ico is an exception worth mentioning. ICO images are not compressed, so gzip performs very well on them.
    – a cat
    Jul 20, 2018 at 13:06

This would depend on what is more important, client decompression resources (time, processing power, memory, etc.) or network bandwidth.

Example 1) Your client systems are either very close to the server (say on a local network) or have high speed connections, however they are very low powered (perhaps embedded systems with limited resources). You would NOT want any client side overhead (un-gziping) and could easily afford the transfer overhead (a few bytes makes no difference in the real world on a local network).

Example 2) Your clients are all very high powered systems (say, above average office workstations) however there are thousands of them and your server only has a limited bandwidth allocation. In this scenario the end users can easily afford the overhead and every byte matters to the server. gzip away!

Real World) You are likely NOT better off gziping your images. Modern systems can well afford the processing however, if you have real world expectations someone will use a cell phone or other low powered system. Additionally you are imposing the restriction that the receiver be able to un-gzip. Shouldn't be a problem most of the time, but why limit anyone? The size savings will be trivial and the processing overhead will not be for any system. The greater the size savings you should expect even greater processor overhead so any time you save in the transfer over any normal type of connection has a chance to just be re-created by the time taken to process the gzip into something usable.

Your best bet IMO is to look into higher optomization and alternative image formats. Not all JPEGs are created equal. Example: save an image as a jpeg in photoshop, then "save for web and devices" as jpeg, the file size should be drastically different with the same quality settings. Additionally the "save for" option provides many more options for fine tuning quality and file size. Don't be afraid of more "dated" formats like GIFs as well. If your image displays nicely within the limitations of the GIF format it's likely to be much smaller still, and offer extra benefits like transparency...

  • Thanks for your detailed response. The scenario I'm talking about is a scenario that involves millions of existing images, partially optimized, on an e-commerce website. So it is clear, that the highest priority is quick rendering at the client side, and that the clients' machines are average-and-less powered. Saving in a different format is not an option [huge investment]. The best solution would be in a case like this [so many existing images], to have a tool that could optimize all jpeg files in a folder. Are you familiar with such a tool?
    – charlie
    Jan 27, 2011 at 22:37
  • There's a free command line utility called jpegtran which optimizes JPEGs, it might be able to batch process all images in a folder so that might be worth investigating. Jan 28, 2011 at 11:46

No, in fact it could make things worse. From Yahoo's Best Practices for Speeding Up Your Web Site:

Image and PDF files should not be gzipped because they are already compressed. Trying to gzip them not only wastes CPU but can potentially increase file sizes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.