2
votes

I read about gzip compression and png image compression and they both use DEFLATE alghorithm, but I'm not sure that the implementation of that algorithm is the same. Also, if it's the same algorithm, then what is the difference between those compressions, besides the fact that png compression uses delta filtering before DEFLATE?

2

2 Answers

1
votes

DEFLATE is a compressed data format, not an algorithm. Both gzip and PNG use the deflate compressed data format exclusively, with different wrappers around that compressed data. Both can have multiple deflate streams.

gzip is a command-line utility with an implementation of a DEFLATE-compliant compressor. Sometime after gzip was written, the same person who wrote that compressor, Jean-loup Gailly, adapted that code for zlib, a general-purpose compression library. zlib was written expressly for the purpose of enabling the adoption of the PNG format for images. Most PNG compressors use zlib.

As zlib's compression code was adapted from gzip's, the implementation is very similar, but not exactly the same. If you compress the same data with the compression code in gzip and zlib, you will generally get different results except for short input. There were changes in how the compressor decides to emit a deflate block, and in the tuning parameters of the algorithm.

0
votes

Short answer is yes, they use the same deflate algorithm. See the first answer in this link for the gory details. Below is an extract

The zlib library provides Deflate compression and decompression code for use by zip, gzip, png (which uses the zlib wrapper on deflate data), and many other applications.