PDA

View Full Version : Is lossless JPG compression better than lossless PNG compression with large palettes?


Shining Arcanine
Fri 28th Jul '06, 8:35pm
A user on my forums wanted to use a 32bit PNG avatar that exceeded the 16KB limit that I enforce on my forums so he asked for help condensing it without sacraficing image quality. I used Fireworks and I tried various types of compression. PNG 24 brought it down to 16.8 KB from 24.05 KB. PNG 8 resulted in banding, which disqualified it. I tried various varieties of PNG 8, including dithered and non-dithered, adaptive and web adaptive, but they all were unacceptable due to the color banding. I then tried a JPEG, which by default was set to 80% quality, resulting in artifacts. I gradually began to raise the quality, from 80% to 85%, 90%, 95%, 96%, 97%, 98%, 99% and finally 100%.

I was amazed. The file size was 12.2 KB, without any loss in quality of any kind. Where the PNG specification could only losslessly lower the file size to 16.8 KB, the JPEG specification got it down to 12.2 KB using lossless compression. After compressing a few images, it seems that lossless JPEG images have superior compression when color palettes exceed 8 bits and it also seems that lossless PNG 8 images have superior compression when color palettes are equal to or are lower than 8 bits.

http://en.wikipedia.org/wiki/Jpeg#Entropy_coding
http://en.wikipedia.org/wiki/PNG#Compression

It seems that JPEG's entropying coding compression is superior to PNG's deflation compression when it comes to larger color palettes. Am I wrong or have I just stumbled across something? I cannot find any online literature stating this and Wikipedia's PNG verus JPEG comparsion in its PNG article fails to consider the existance of lossless JPEGs.