Is gzipping images worth it for a small size reduction but overhead compressing and decompressing?

54,088

Solution 1

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.

Solution 2

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.

Share:
54,088

Related videos on Youtube

Stephen Ostermiller
Author by

Stephen Ostermiller

Updated on September 17, 2022

Comments

  • Stephen Ostermiller
    Stephen Ostermiller over 1 year

    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.

    • Admin
      Admin about 13 years
      If your server bottleneck is closer on network than on CPU, sure. Else, there might be lower hanging fruit.
  • Admin
    Admin about 13 years
    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?
  • Admin
    Admin about 13 years
    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.
  • a cat
    a cat almost 6 years
    favicon.ico is an exception worth mentioning. ICO images are not compressed, so gzip performs very well on them.