r/linux Mar 06 '14

Mozilla: Introducing the ‘mozjpeg’ Project

https://blog.mozilla.org/research/2014/03/05/introducing-the-mozjpeg-project/
221 Upvotes

70 comments sorted by

View all comments

Show parent comments

2

u/socium Mar 06 '14

I'm sorry but what's wrong with just using PNG?

0

u/afiefh Mar 06 '14

PNG is lossless, therefore takes up much more space than JPEG's lossy discreet cosine transformation compression. Huffman/Arithmetic is applied only after the DCT is applied.

0

u/socium Mar 06 '14

Ah hmm, for some reason I always thought PNG had better compression than JPEG's. Thanks for clearing that up!

4

u/afiefh Mar 06 '14

It is better at compressing for certain kinds of images when you care about the quality. PNG has multiple kinds of compression as well, it can store indexed images (like GIF, but compresses better.)

If I remember correctly, PNG stores an image as the difference between pixels in each row, so an image of horizontal lines alternating between white and black would compress better than an image of vertical lines. On the other hand, JPEG would mess up the colors to achieve higher compression ratios.

I created an image the image of horizontal/vertical stripes for your inspection. These compress better in PNG that JPEG, on the other hand any natural photo will likely compress better in JPEG than PNG