Non zlib-based Compression

It is not compulsory to use the official releases of zlib, as produced by Info-ZIP. You may use any data compression library or method, as long as it produces valid zlib streams, according to RFC1950 and RFC1951.

The following sample method may look odd, but it enables you to use any program that produces Deflate-compressed streams (that is, any program that produces zip files):

  1. Extract the raw file from the IDAT chunk (there are other painless methods for this step, but I am presenting it as-is to help you make a better idea of its purpose)
  2. Compress (zip) the raw file using any zip-based compressor, such as PKZIP, WinZip, TurboZIP etc.
  3. (Binary) extract the compressed stream from the zip file (must know the zip file structure).
  4. Insert the extracted compressed stream in the file where the IDAT chunk was initially saved, instead of the original one. All the other information (chunk "IDAT signature - if present, zlib flags, Adler32 checksum) shall remain unchanged.
  5. Use MNGEye or TweakPNG to reinsert the newly created chunk in the PNG file. These programs will automatically update the length and the CRC of that IDAT chunk.
Felipe Machado has provided a nice program called png2raw [Win32 only] (thanx!) that does the complete job required by the first step. N.B. it decompresses the IDAT chunks, not the image from the logical point of view, so the result is not a raw image file, but a raw sequence of bytes obtained after delta-filtering and possibly interlacing.

Here is an example of an image that was compressed using the internal compression method of the old Norton Commander version 4.0 (May 1993). It was the only program that produced a compressed stream less than 64K.
 
Compression method Length of the IDAT chunk
zlib, normal (default) compression 66774
zlib, maximum compression 65662
pngcrush, zlib with maximum compression and TOO_FAR = 32767 65809
Info-ZIP zip 2.3, maximum compression (-9) 67076
PKZIP 2.50/Dos, maximum compression (-exx) 65572 (the fastest compressor)
NC4.0 zip, maximum compression 65501 (the smallest output)

Other such third-party software is ARL viewpng (sorry, not available) and ColosseumBuildersImageLib (not included in tests yet).
If you know about any such software, please let me know.
I don't even mind if you do a comparison like this, including other software too, and then send me the results :-).

Don't look at the ranking, because it is completely different for different images. For example, this is one of the few examples where a value of TOO_FAR bigger than the default value (4096) produces a longer, less-compressed stream.

And this is the (optimal) image:

I would also appreciate if you let me know of any image that can be compressed more significantly (i.e. the difference between "standard" best compression and "third-party" best compression is more obvious) using a third-party compressor and not a zlib-based compressor.


Back to PNG-Tech Home