Saturday, April 18, 2009

Which image file format to use, JPEG or PNG?

When I deal with images, I almost always use either JPEG or PNG. JPEG is good for pictures with a lot of colors like photographs. PNG is much better if you have limited colors like screen captures of a program or plot.

I use plots/screen captures that rarely have more than 256 colors in my reports all the time. I save them as PNG's because the picture will be clearer (PNG uses lossless compression) and the file size will be smaller than JPEG. The following plot saved as PNG takes 3KB of space while the JPEG takes 8KB:

This photograph, however, takes 321 KB in PNG and only 51 KB in JPEG:

Moral of the story: Use PNG for plots and screen captures, JPEG for photographs.

No comments: