Is gzipping images worth it for a small size reduction but overhead compressing and decompressing?
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.
Related videos on Youtube
Stephen Ostermiller
Updated on September 17, 2022Comments
-
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 about 13 yearsIf your server bottleneck is closer on network than on CPU, sure. Else, there might be lower hanging fruit.
-
-
Admin about 13 yearsThanks 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 about 13 yearsThere'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 almost 6 yearsfavicon.ico is an exception worth mentioning. ICO images are not compressed, so gzip performs very well on them.