What is lossless JPEG? :: Digital Photo Secrets

What is lossless JPEG?

by David Peterson 5 comments

You've probably heard a lot about JPG vs. Raw. These are two file formats that most modern DSLRs offer, but you may have also heard about another one - "lossless JPEG".

What?

To understand the differences between Raw, JPEG and lossless JPEG, we first have to understand the difference between "lossy" and "lossless" file formats.

You probably shoot in JPEG at least some of the time. JPEG is the default file format for most digital cameras, and unless you've got a good education about the Raw file format, the chances are pretty good that JPEG is the one you stick with. But the chances are also pretty good that you're really not sure why.

JPEG is a compressed file format. What that means is, when you shoot an image as a JPEG, your camera does a quick evaluation of the file and then discards some of the image information. The reason it does this is to make the file smaller. Small files take up less room on your memory card, they download to your computer faster and they don't hog hard drive space.

How JPEG works

JPEG is block-based compression. Every time you shoot an image as a JPEG, your camera captures that image and then divides it up into blocks of 8x8 pixels. It then uses a built-in algorithm to analyze the information within each one of those blocks. When it does this, it's basically deciding which pixels are important and which ones aren't. Let's say you're photographing the surface of a pool—most of the water is going to appear as blue, but there are going to be some subtle variations in those blues. Depending on how much compression your camera is doing, it may just discard some of those subtler shades of blue since the difference between them is going to be very difficult for the human eye to detect anyway. That information is deemed unimportant, and discarded, and the result is a smaller or compressed version of the image. This is what's called a "lossy" file format.

With a JPEG file, you can control the amount of compression in your camera's settings. The "fine" setting is going to give you a JPEG that probably won't have any truly noticeable loss of quality, but once you get into the standard and low quality settings, you're going to see compression artifacts, especially when viewing your files at 100 percent. These artifacts have hard edges and may look pixelated or even blocky, depending on how much compression you've done.

Another drawback to shooting in JPEG is the generational loss of quality. Every time you open up, save and re-save a JPEG image, you're losing a little bit of quality—even if you made no changes to file size or image compression. That's why it's always best to edit copies of your JPEG files, never the original version.

The Raw format

Raw, on the other hand, is a "lossless" file format. When you shoot in Raw, your camera captures the entire scene and all its different tones and saves them into a file, and that's where it stops. It does no evaluation of the scene, it makes no decisions, and it discards no information, even those subtle shades of blue that your eye probably can't detect. It keeps all that information and saves it onto your memory card, and as a result you'll probably have a really big file. Raw takes up a lot more space on a memory card and on your hard drive, and it takes considerably longer to move from one place to another. It's also slower to write—you may not be able to use burst mode when you're shooting in Raw, because your camera won't be able to keep up with the action when it's busy writing all those massive files.

Lossless JPEG

Lossless JPEG, then, is sort of like a hybrid between JPEG and Raw. Let's look at JPEG 2000 (a form of lossless JPEG) as an example—instead of block compression, this format compresses an image by converting it into a set of mathematical expressions (called "wavelet" compression). The result is a file that is 25 to 35 percent smaller than a standard JPEG, but with much better image quality. Not all JPEG 2000 files are lossless, but if you're using the format you have the option to save your file with lossless compression. JPEG 2000 is one of the standards used by the US Library of Congress for digital preservation. It is also used in movie editing and distribution.

I'm sure that all sounds pretty good to you, but the thing about JPEG 2000 and lossless JPEG in general is that it hasn't really caught on with consumers. There are a few very good reasons why: first, it's a lot slower than the standard JPEG file format. Second, standard JPEG is more portable and it's already got a very strong foothold on the internet, where it's easy to upload, display and email. And third, camera and software manufacturers would have to spend a good deal of time rewriting all of their code in order to actually make lossless JPEG work on their cameras. So making the switch really isn't seen as cost effective, especially since the performance gain is only 25 to 35 percent over JPEG, and hard drive space just isn't expensive enough for that to be seen as a huge savings.

But the final reason why it hasn't caught on is because lossless JPEG is hard to sell over Raw, which is already available in most DSLRs and many point-and-shoots. Raw is already a lossless format, and most photographers don't see the need to trade something that already works for something that really isn't any better.

Saving files as lossless JPEG

Lossless JPEG has yet to make an appearance in the popular consumer photo editing tools for many of the same reasons why we still don't see it as an available file format in consumer cameras. It's still seen as redundant, even though there's arguably good use for it in web applications. Theoretically, lossless JPEG could boost the accessibility of a website by speeding up download times, without any loss of image quality. So there are tools out there that you can use to losslessly compress your JPEG files, which could be quite useful to you if your goal is to add them to an image-heavy website or you have very limited storage space on your computer. Some popular utilities include jpegoptim, jpegtran, jpegrescan and mozjpeg. These tools use different algorithms to do the same basic thing—reduce the size of your JPEGs without any loss in quality. You can also use them to perform lossless image rotation (did you know that every time you rotate a JPEG image in Photoshop it loses quality?), lossless resizing and lossless cropping.

But should you?

The question is really a personal one—these tools are not really mainstream, and you'll have to use them in addition to whatever image editing tools you already use. And if you're shooting and saving your files as JPEGs anyway, you've already got some unrecoverable compression that lossless JPEG is not going to be able to get back. The only time this is really going to be useful for you is if your goal is to reduce the size of the JPEG, and most of us don't do that unless we're trying to improve the load time of an image-heavy website, or if we're emailing a lot of files and we have inefficient internet services.

Lossless JPEG compression can be useful for reducing space on your hard drive, but depending on how many files you want to compress batch processing could be time-consuming. On the flip side, hard drive space is not expensive, and we're mostly talking about a 30% savings. Ask yourself if it's worth the time and effort to compress all those files for the sake of a 30% reduction in hard drive space, or if it would be less of a headache to just go out and buy an external hard drive instead.

Conclusion

Is lossless JPEG the wave of the future? Almost certainly. But until it reaches the point of widespread implementation in camera, as well as being readily available on our favorite consumer-level post processing packages, you're probably not going to see it a whole lot. There's definitely something to be said, though, for compressed files that have no loss in quality. JPEG is on the whole a very useful file format for the majority of photographers, but not everyone understands what they're losing every time they rotate a JPEG or open and save it. I do hope that one day JPEG-caused loss of quality won't be an issue for anyone, but it's going to require some growing pains. It will be pretty interesting, though, to see how it eventually unfolds.

Most people think this post is Interesting. What do you think?

Comments

  1. Wolf says:

    You say a lot about what lossless JPEG could do and would do, but unless I just don't see it, even in the section titled "Saving files as lossless JPG", you don't really say how to safe them as lossless.

    • David Peterson says:

      Hi Wolf,

      Thanks for the pickup - I should have mentioned how to save.

      Lossless JPG is not supported by most image editors - I wrote this article because those who have the ability have asked me what the difference is.

      Look at the 'save as' part of your editor. If you see an option under JPG or JPG2000 to save lossless, then your editor supports it. Otherwise, stick with the other lossless formats like TIF or RAW.

      David.

  2. Bruce says:

    I usually use jpeg then convert to .tiff to edit. Once edited and saved as jpeg the file is smaller.
    Did I lose some of the image when I switched to .tiff or when I saved the tiff as jpeg

    • David Peterson says:

      Hi Bruce,

      When you save as tif, you won't lose any information as the tif compression is usually lossless. When you save as jpg, that's when you'll start to lose information.

      Note: It is possible to 'lossy compress' an image in tiff format, but not common. So while I said above that you won't lose any information, make sure your editor saves in a 'lossless' format to be sure.\

      David.

  3. john says:

    Why didn't you mention that RAW have 14bit per colour and any JPEG just 8?

  4. charles says:

    Good education

Leave a Comment

Your email address will not be published. Required fields are marked *