Friday, May 10, 2013

How do I extract an embedded JPEG from a RAW file?

Short answer:


exiftool -b -JpgFromRaw IMG0001.NEF > test.jpg

Long answer:

Most RAW files contain not only the raw data that was captured when the picture was taken, but also a jpeg file which can be used to quickly show the image before the RAW has been completely interpreted.

Some programs that pretend to handle RAW files actually just extract the jpeg and displays that one to the user.

There is rarely any reason to extract the jpeg manually, but if you want to, you can use the command tool above using exiftool which is a tool available for Windows, Mac OS and Unix/Linux.

Just replace "IMG0001.NEF" with the name of your RAW file and "test.jpg" with the name of the jpeg you want to create.

Update: The name of the preview is not the same for all RAW files. That's why Jener in the comment section succeeds with PreviewImage but not with JpgFromRaw. In general, if you have problems with the command, try the exiftool documentation page

6 comments:

Jener Gomes said...

Hello,

I had a general HD failure (Sansung ones...) and it lost thousands of photos, I am recovering many of them and I noticed that some CR2 have a perfect preview, however a corrupted RAW.
These parameters doesn't work to me, but those from https://forums.adobe.com/thread/354749 yes:

exiftool.exe -b -PreviewImage -w %f.jpg -ext CR2 -r .

They give me a 1600x1200 Jpeg, much better than nothing. =)

Toph said...

How the heck do I use this? I have noooo idea what I'm supposed to do with it!
Any info would be great!

Magnus Lewan said...

Toph, I think this is a case of "if you do not know you need it, you do not need it." Most of us never need to extract jpeg from RAW files. I knew it was possible, figured out how to do it, and put the info there, in case someone was curious.

Laurent said...

I use it to send the lighter jpg to my server while retaining the RAW in a hard disk connected to my remote Nikon for future use

Unknown said...

Thanks @Jener . I had a photo shoot for a client's property and only came home to realize over 23mb files Jezzz.

Was just thinking how i'll go back and tell him i need to do a reshoot for my property listing website, digitalrenter.com.
Imagine uploading 10*23mb pics on a website :( .

This worked for me like charm.
exiftool -b -PreviewImage -w %f.jpg -ext CR2 -r .

converted my 23mb raw (cr2) file taken from canon to 2.3mb jpg file with same quality.

Thanks again.

Unknown said...

Hi!!!
I had to recover raw files from a portable hard drive and most of them are corrupted. I attempted to use exiftool to extract jpegs from the raw files, using your command among a few others, only to get a "file not found" result, even though the images are sitting on my desktop. I have even dragged the images into the terminal window and it won't work either. I had never heard of exiftool until a couple of hours ago, any input?
Thanks!