LZW-GIF Compression Can Be Sometimes Better Than Deflate Compression

Update: Some users have reported that even the image shown below can be compressed as PNG better than shown in these reports, and better than GIF. So:
Unless I find a non-trivial replacement image whose GIF stream is shorter than its PNG IDAT stream, this article has no purpose... which, in fact, is a good thing! :-)

First of all, I want to say that zlib/Deflate-based PNG compression is significantly better than LZW-based GIF compression, in most cases. This page is intended to be a collection of very few special cases, when the LZW-GIF compression performs better than the PNG compression.

I am not talking about those tiny GIF files that are smaller than PNGs only because the PNG overhead is a few bytes bigger. The smallest, single-pixel GIF has 31 bytes, while the smallest, single-pixel PNG has 67 bytes. I am talking about GIFs that actually contain something interesting to see.

I am not talking either about GIF files that are smaller than their PNGs just because the PNG version contains "bogus palettes" (palettes with dummy entries). Unfortunately, there are some software that produce such PNGs, and there are some people who believe that the compression algorithm is to blame, and not the encoders that actually produced these PNGs.

Finally, to consider a PNG image for comparison, it must be optimized first by software like pngcrush, in case that the PNG encoder that created it does not produce PNGs at their optimum size in general.

The first image is taken from http://www.feynman.com and it is a 65x93, 30-color picture of the physicist Richard Feynman.
Non-Interlaced GIF
Image block size: 2570 bytes
File size: 2680 bytes
Interlaced GIF
Image block size: 2584 bytes
File size: 2694 bytes
Non-Interlaced PNG
IDAT size: 2564 bytes
File size: 2723 bytes
Interlaced PNG
IDAT size: 2803 bytes
File size: 2962 bytes

Do you expect to see here a second image? Have you encountered such images? Let me repeat: I am looking for special cases when the GIF-compressed stream (i.e. not the total file size) is smaller than the PNG-compressed stream. If the entire PNG file is bigger than the GIF file only by a few bytes, because of the overhead of the PNG format, that is not an acceptable example.

I didn't find other such image, yet (Ok, I found, but it had a such poor quality, that I did not consider it relevant for these comparisons). If you find one, and if it would be possible for this site to host it, I would be glad to host it. However, before sending me such images, please make sure that the GIF is smaller than *both* non-interlaced and interlaced PNGs. It's about small images anyway, so I do not expect to treat interlaced and non-interlaced images separately, as interlacing does not have any significance for tiny images.

Back to PNG-Tech Home