RAW vs. JPEG: Both Have A Place And Time – Photography Basics

Photography Basics - Understanding Shutter SpeedJPEG vs. RAW: It need not be a war

Most every post you see on JPEG and RAW file formats pits them against each other; RAW vs. JPEG In A Cage Match To The Death!! You’ll also hear experts tell you you have to shoot in RAW or you suck.

The funny thing is, those experts don’t know how you shoot. They know how they shoot and what works for them. Bravo be to thee, but don’t make me fit into their world, please.

I’m hear to tell you you can shoot in either JPEG or RAW and life will, in fact, go on. Heck, you might even be happy. But first, lets me arm you with ample information to make your own decision.

Nuts and bolts of light and your sensor

Jargon time: RAW is as it sounds. It is raw information from your camera’s sensor. JPEG is an acronym you will never remember so don’t sweat the small stuff.  It is a type of compression to take raw information and squish it down.

In the post How Your Camera Works I mentioned the use of a buffer because most cameras can shoot faster than they can write information to a memory card. JPEG helps alleviate that (and can do away with the wait altogether) by smooshing down that huge RAW file size from something like 30MB to maybe 6MB.  Impressive, huh?  It comes at a price, though.

Let’s look at this visually using the diagram of the image sensor inside your camera from the ISO post.

ISO sensor patternEach of those spots is a photo sensor set to detect only the amount of light hitting it of the appropriate color. This part is no exaggeration; that green dot only sees levels of green, the red only red and blue only blue. That’s it, just those three colors. (Note: hip new sensors will bend this rule around, but the idea is the same.)

RAW format is set to record the data from each and every pixel. To make the math easy I am going to exaggerate a bit: If a sensor has 20 megapixels (million pixels) and each pixel’s information is roughly one byte, that would be 20 megabytes of data (technically it is 1,048,576 bytes to a megabyte, but let’s round numbers to annoy geeks)=20MB. A decent sized file. I’ll illustrate this in a minute.

JPEG shrinks all things

JPEG vs RAW - Infinity WarWhat JPEG does to compress this 20MB of information is to group pixels together and write not individual pixel bytes, but the combined numbers which equal a color. The sensor pixels in most cameras are set to record 256, 4,096 or 16,384 different tones of just each color (red, green, blue, or RGB).

That is, in 8bit mode, there can be 256 different intensities of red recorded in each red pixel. 12bit sensors go up to 4,096 different intensities and 14bit is 16,384 different intensities. Sorry if I’m getting techy, but if you want to go further, Canon has some good info.

Let’s keep it simple and go with 8bit. RGB are the primary colors and they are combined in various ratios to represent all colors. So pick a trio of pixels above in each color. The true color of the light hitting the sensor, let’s say a nice purple, might be represented with intensities listed like this: Red: 99 Green: 21 Blue: 108.  It’s just like mixing paint in an art class or at the home improvement store. Add in certain quantities of each primary color and voila! A new color. Yay!

The RAW file would have recorded each and every pixel just as its R or G or B value, individually (and then put in zeros for the other colors, such as R:99 G:0 B:0). Thus its bigness. JPEG will take those three pixels’ information and only record the final number that they all make up.

It’s diagram time

First let me show how the information for a RAW file will be recorded. I’m going to overlay some color that looks like this:

That purple, as expressed in RGB is R:131 G:53 B:163 and the orange is R:217 G:124 B:25. Does that make sense? Just remember: mixing different amounts of paint. Now I’ll make it slightly transparent and lay it over the sensor grid.

Next I will fill in the appropriate data each individual pixel will see. Remember, each pixel can only see its own color in varying degree of intensity. I am using close, actual numbers here in a R G B, top to bottom format.

JPEG and RAW sensorMesmerizing, isn’t it?

How to read the numbers

Do you see how I got each of those numbers? Purple is made up of 131 parts Red, 53 parts Green and 163 parts Blue. A green sensor can only record green values, so it puts a zero for the red and blue placeholders.

While they are zeros, they still take up space to record. In RAW recording mode, this information is passed on to the file just as it is seen here (how it is viewed on the computer afterward is another story).

JPEG is going to cheat a bit. Its information will look like this (don’t mind the difference in triangle colors, they are only different to make them easier to see):

JPEG and RAW sensor
I’m not going to fill in the entire grid for sanity’s sake. And this drawing is not 100% accurate in the way the compression actually gets done, for the tech geeks out there. It’s a representation of how the process works.

In essence, the amount of data, over all, has been reduced and algorithms in the camera will compress this a bit further. The real import of this information will becomes apparent when looking into White Balance (Hint: it’s way easier to adjust White Balance on a RAW photo than a JPEG one).

JPEG vs RAW - Infinity WarFor now, just understand that JPEG gives up some of the original light information when it does its compression. In the example above, where two colors slightly cover the three sensors (the yellow triangle) what happens to the original information about the blue pixel in that group?

Look above, it was 0,0,25 but now, because it is being combined with a bit of the sensors where purple is striking, it gets adjusted in the end compromise to shrink. That true color, the amount of blue that hit that pixel, is lost when compressed. That’s why JPEG is known as a lossy (as compared to loss-less) format. Not all the original data is transferred.

Which file format to use?

Now that your brain and mine are fried by the math aspect, how does this apply to my original statement of “Use what you want”?

Simple; If you always want all the image data to have maximum ability to fiddle with it in the computer, go RAW.

JPEG vs RAW - Infinity WarJPEG, on the other hand, is valuable for certain situations:

  • When you just don’t care
  • Shooting for speed if you keep hitting a full buffer
  • If you need to conserve space on a nearly full card while out in the tropics away from Amazon
  • If you don’t want to fiddle with RAW files in a computer afterward and just want to post them to Facebook quickly
  • You hate large files and the time it takes to transfer them to your computer

It comes down to…

RAW isn’t as easy to just shoot and then email to a friend. It has to be converted first to another format, sometimes JPEG, for emailing. Lucky for us, cameras now have the ability to shoot in both JPEG+RAW at the same time! I do this often when traveling and I know I want to quickly post sample images.

I will shoot in the smallest image size for the JPEG version and that makes a nice small file easy to post or email without the need to convert it. Then the RAW file will contain all the data and I can make adjustments in the computer at home more eloquently.

JPEG vs RAW - Infinity WarDANGER: I will warn you that White Balance is set and written into the JPEG file when it is created (as well as some other items). You can’t change this easily. But RAW does allow for easy White Balance changes. Super easy in the computer, as a matter of fact. Intrigued? Click the link above.

DOUBLE DANGER: Every time you save a JPEG file in a computer (or even rotate it) your computer will compress it again. Meaning it will degrade just a bit every time you play with it.

Compression options

Lastly, what about the different compression settings? These typically look like (Nikon)”Basic, Normal, Fine” or (Canon)”Normal, Fine, Super Fine” and still something different for Sony, Pentax, etc… Those levels represent how much compression happens to the file.

Staring from the top of both, Fine and Super Fine start with triangles that look like the diagram above; nice and small and the most detail obtained. As you move to Normal and Fine, respectively, the triangles will get bigger. Now instead taking three pixels and combining their data, the triangle will suck up six (and there will be a funky type of overlap) and the file size will get smaller still.

But guess what? Even more finite data is lost because the triangle will average the color inside of it and that will change the larger it becomes. Finally, in Basic and Normal, the triangle is larger still, the file smaller and the picture not as sharp.

Conclusion and compression suggestion

My suggestion: go with the highest compression you can when shooting JPEG(Fine and Super Fine, respectively) unless you are just about out of space on your card with no backup.

JPEG vs RAW - Infinity WarIn closing, realize people typically migrate towards RAW from JPEG as they get more comfortable with post-processing (playing with the image in the computer afterward). I would never tell my Dad, for instance, to shoot in RAW. He really has no reason for the types of images he shoots and he doesn’t like having to mess with pictures in a computer afterward.

Many people start with JPEG because they know how to handle it. Then as they want more control over editing the image in their computer, they start to see the clear advantage RAW possesses. It presents all the original, unedited information when the shot was taken.

Smartphone Note: Your phone will almost certainly shoot in JPEG unless you set it to RAW (not all phones allow for RAW, though).

One last thing: If you want to take this a step further, check out Jim Goldstein’s post on the DNG file format (used in the computer after import) to expand your knowledge. He also has some more info on the JPEG and RAW conversation with a list of Pros and Cons. I suspect Jim is himself a con running from the law, posing as a mild mannered photographer.

Questions?  Pop ’em like Pez in the comments section below. or email me at peter@peterwestcarey.com.

Photography Basics – A 43 Day Adventure, and its companion 40 Photography Experiments, are series written by professional photographer Peter West Carey. The series are designed to unravel the mysteries of photography, helping you can take better pictures. Subscribe here to receive all the updates and bonus material. Your comments are always welcome.

Photo ToursIf you enjoy the series, consider learning photography first-hand on a professionally led international photo tour in Nepal or Bhutan. More information can be found at Far Horizon Photo Tours