Page 1 of 1

Extracting jpeg thumbnail image from camera raw

Posted: Wed Feb 26, 2020 2:24 pm
by Simon Knight
Hi,

I am writing a utility application to aid me in managing raw image files taken on a digital camera. I decided it would be useful to be able to view thumbnails of the images from within my application and the stack that is attached demonstrates one method of locating and extracting a jpeg from a raw file.

My code is crude and probably a bit of a kludge. Its a kludge because it searches for a jpeg header rather than following the crumb trail of the "Image File Directories" (IFD) that most raw files contain. The reason is simple enough as I could not figure out how to get from an IFD to the Thumbnail.

The code is crude because I am certain that the search can be speeded up, probably through a proper search method. At the moment I just start at the beginning and work my way through the file. So users of cameras that produce very large files beware.

From inspection most raw files hold two jpeg files with the smaller thumbnail occurring earlier in the file. So my code just grabs the first that it finds.

I am interested in increasing the speed and testing it against a wide range of raw files. So far it works with files from:
Nikon D70 .nef
Nikon D300 .nef
Olympus OMD EM5 mk1 .orf
Panasonic Gx7 .rw2
Panasonic G80 .rw2
Panasonic D9 .rw2

It fails to work on raw files from:
Canon G5 .crw

Any input welcome