Friday, July 12, 2013

4+1 Tips on JPEG Compression

As you have probably noticed, summer is a slow time for the blog - one reason being, ironically enough, that it's a hectic time for photography! So, apologies for the lack of updates. But hey, you want me out there in the field, testing equipment, taking photos, discovering new things to share with you, right? :)

But in the meanwhile, here's 4+1 great tips for and secrets about JPEG compression. JPEG is the format used by the vast majority of users. For many of them it's the only format they ever use (indeed, some low end cameras don't offer any other), but even RAW users eventually save their images as a .jpeg file that will be posted online or sent to a printing service.

The Issue:
JPEG for images is what MP3 is for sound files. It compresses the information to reduce the size of the file. You can control the compression ratio to favor size or quality (smaller file size = more deteriorated image quality). Depending on the image and the compression, in most cases no visible difference can be spotted, while the size can be reduced from 14MB to 2MB or less. Sounds good, right? Well, the problems begin once you realize that these missing 12MB are, after all, lost information. It's gone forever. The trick is, how do we make sure we don't throw away something we need.

The image on the left was saved with 10% compression ratio (so, very close to perfect quality). The image on the right, was saved with 75% compression ratio (so, much of the information is thrown away, and it shows)

The Solutions:
Here are 4+1 tips to help you do the right thing when compressing JPEG images.

1) NEVER save, load, re-edit, re-save a jpeg file. If you have no RAW file to work on, keep the original jpeg file, create a copy, and work on that. Do all necessary editing in one session, save as JPEG, and don't work on that again. If you change your mind and you realize there's more editing to be done, start over from the original file (which you will copy again). The cycle of load-edit-save-load-edit-save on the same jpeg file can be catastrophic for image quality

2) If you can afford it, always choose the best quality on the jpeg compression save dialog. It seems self-obvious, but many people choose "good balance" or something like that (depending on the program). If you have no space constraints, why would you do that?

3) JPEG compression understanding: Compression, as we said, throws away information. "From where", you might ask, and you'd be right to wonder. More important, still, is how visible it will be. To spare you the technical details, suffice to say this: The more detail exists in an image, the more prone it is to jpeg compression. In other words, an image of an even blue sky holds significantly less information than an image of foliage or textures. Keep that in mind when you select your compression. Highly-detailed scenes will look hideous if the compression is over a certain threshold. But read on:

4) But also even scenes, like the blue sky example I mentioned, will eventually degrade. In highly-detailed scenes, jpeg compression mostly looks like loss of well-defined edges (you get the so-called jpeg jaggies; pretty much random edge artifacts) and also (dis)coloration. On even scenes, conversely, it looks like posterization. Check the example below. Simply put, there is no such thing as a free lunch.

Extreme JPEG compression results in posterization issues


Bonus Tip for Using Images for Facebook
As you might have noticed, the quality of images you upload to Facebook is significantly degraded. The reason? Facebook, to save space, applies a pretty aggressive compression on your images. There really is no way around it, frustratingly enough. The only thing you can do is damage control:
- When uploading on Facebook, ALWAYS use the best quality settings to save your images
- Do not upload small-sized photos. I would advice images that are 1500 pixels or longer on their long side.

No comments:

Post a Comment