My ramblings, my photos, photography, image editing, etc.

Extracting JPEGs from RAW

This is a rare posting to the Photography side of my website. I should do more of them. If I do I might get comments that point me in a better direction. This post seems quite long but I find the process quite quick and simple.

RAW files from my camera are, as the name suggests, the raw data from the camera and its sensor. I am sure I am simplifying things a lot, and I may actually be wrong for some cameras, but it helps in the understanding of the principle. Each pixel in a camera is made up of 3 sensors that record one of 3 colours and the data from these sensors form part of the RAW data along with how the camera is setup. (Since originally writing this I have found that there are often 4 sensor points per pixel – 2 green, 1 red and 1 blue) To view a RAW file the application has to be able to understand the data and then apply the recorded camera settings to that data before displaying. For example the file contains all the data for the 3 colours for each pixel but you might have set your camera to black and white. The application reads the RAW colour data and then displays it as black and white. This is what the DPP software that comes with my Canon camera will be doing.

On my Canon 7DMkII the RAW file includes an embedded JPEG where the camera settings have been applied to the RAW data. I suspect that image viewing software uses this embedded JPEG which is probably stored within the file in a standard way – at least with a particular manufacturer. In that way the image viewing software will still work with the embedded JPEG when a new camera, with new RAW data, is released.

On my computer I find that Irfanview, that I use to do the first review of image files, displays JPEG files quicker than RAW files. This means it can be quicker to go through the many files and get rid of the first 90% of them.

There are times when I am not interested in the RAW file and its mass of data, say when I am taking some shots of the change in use of buildings in Baildon for nostalgia/history record purposes, where the JPEG with perhaps some simple contrast, cropping and straightening applied is more than adequate.

For the 2 reasons above I often use an Open Source program called UFRAW in “batch mode”. UFRAW has a user interface that lets you manipulate the data of RAW files and export as graphics files e.g. JPEG. I no longer use the user interface – I use Canon DPP instead. But I do use UFRAW in batch mode to quickly extract the JPEG from RAW files.

mkdir embedded
“C:\Program Files (x86)\UFRaw\bin\ufraw-batch.exe” –embedded-image –out-path=embedded *.CR2

Content of embedded.bat file

Edit: I now use exif.tools to extract the embedded JPEGs.

I have installed UFRAW and created a file called embedded.txt which contains the 2 lines of text shown above.

mkdir embedded

This creates a new directory called “embedded” under the current directory.

“C:\Program Files (x86)\UFRaw\bin\ufraw-batch.exe” –embedded-image –out-path=embedded *.CR2

This command tells ufraw-batch (installed in the Program File (x86)) to read the RAW files (*.CR2) in the directory and extract the embedded image and put them in the “embedded” directory.

I copy this .bat file to the directory containing the RAW files and run it.

The routine very quickly extracts the JPEG files so that I can either use them straight from there or use a file viewing application, in my case irfanview (and “Yes” I know Microsoft photos viewer probably works quicker, but old habits and all that….), to review and delete those not needed. I then delete the RAW files associated with the JPEGs I have deleted and start processing the remaining RAW files where I probably delete another 90%.

Why RAW?

But why go through all this process? Why not tell the camera to save in JPEG in the first place? To put it simply:- by saving in RAW I have the data from the camera and so the image I can get from that is limited only by the camera. If I save as JPEG I am then applying the limitation of the JPEG file format on top of the limitations of the camera. Each pixel will be limited to a range of colours (admittedly enormous, but it still applies) and the file compression used throws away information that can then not be recovered – and each time you load, edit and save the JPEG more information will be thrown away. (This is why TIFF files are used when you don’t want to loose quality with each save after edits but that’s another topic.)

You can’t beat “getting it right in camera” but there are times when you don’t get it right, or when using one file from the camera, processed once, doesn’t give you what you want. I’ll cover the first example below but the second example is covered in another blog post here.

Straight from the camera

The image above is taken straight from the camera with no processing. It was shot as RAW and shown here as its JPEG. In this case it was deliberately under exposed but I can assure you that in the past I have had examples like this where I have got it seriously wrong .

Processed JPEG

I have then taken the JPEG and processed it as much as I dare. The colours are all wrong and it is very noisy.

Processed as RAW

The image above was processed as a RAW file before exporting to JPEG. It is still not a good photo but the colours are much closer to reality, there is a lot less noise, it is usable. Since taking this photo I have upgraded my camera and would expect to be able to get more from the RAW file, but the JPEG would still be the same.

The photo of Adam was taken during a Baildon Camera Club session.

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.