RT: Extracting embedded jpeg from raw image using RT

I read elsewhere (darktable) on this forum that it is possible to extract the (or an) embedded jpeg from within a raw image using RawTherapee. Given my ineptitude in general with using the command line, and my specific propensity to screw up the syntax of ExifTool, I would like to be able to use RT to do this. I have just read, quickly, through the RawPedia guide and didn’t find a section which describes how this could be done. Any advice?

Google ERawP. works in Linux Mac OS and windows

exiv2 and exiftool are the perfect, lightweight tools for the job:

exiv2 -pp my_image.ext

to print out the list of recognized previews, and then:

exiv2 -ep1 my_image.ext

to extract preview no. 1 etc. (or leave out the number to extract them all).

I just had a look at the docs and rawtherapee-cli to make sure and as far as I can tell this isn’t possible. Maybe I’ll be proven wrong, though.

Create an alias?

alias getembedded='exiftool -a -b -W %d%f_%t%-c.%s -preview:all'

Save that in your .bashrc or .bash_aliasses.

You can now use getembedded RAW.file to extract the jpg(s).

Maybe you know this already, but just in case:

preview:all extracts all the available previews, you might want to narrow that down to the size you want/like (this is camera specific). Looking at one of my Nikons I get these 4:

  • D75_7063_JpgFromRaw.jpg → 6016x4016 (full size)
  • D75_7063_OtherImage.jpg → 1620x1080
  • D75_7063_PreviewImage.jpg → 640x424
  • D75_7063_ThumbnailTIFF.tiff → 160x120 (thumbnail)

Changing -preview=all to -preview=JpgFromRaw gets you the full sized jpg.

If you are on Windows you may use Irfanview. I use it for this purpuse and the jpgs are very easy to extract. You simply call the raw file, view the jpg and save it. Install Irfanview with plugins. The plugins can read many raw formats (like DNG, EEF, NEF, ORF, RAF, MRW, DCR, SRF/ARW, PEF, X3F, CRW/CR2,…).

If on Linux you can use Geeqie; right click the image in the preview, then plugins/export jpeg. No command line needed.

Well, yes, I did know this - but its helpful anyway because it prompts me to ask why the ‘full size’ option fails on both of my digital cameras (Canon G7 X MkII and Fujifilm X-T30). I appears that for both of these the only option is ‘PreviewImage’ - which is much less than I want, in terms of pixel count. I’m sure that the preview I see in darktable’s lighttable, extracted from .CR2 or .RAF images is much bigger than 640 x 424. is there a way to get ExifTool to display those resolution details for all embedded jpegs?

There’s a frustrating lack of consistency with these embedded jpegs. That is why I mentioned this is camera specific. The JpgFromRaw field, for example does not guarantee a full sized jpeg and PreviewImage might be close to full size. It all depends on brand, and sometimes type, of camera.

I don’t know if exiftool has a way to show the size of any of the embedded jpegs (never looked into that). If, like me, you have multiple cameras you can check which option gives you the largest version and create dedicated aliases or a more intelligent function based on extension to extract the jpg.

I’m somewhat lucky in that both my Nikons use the same convention (JpgFromRaw = fullsized) and my Lumix also uses this tag (but jpeg is downsized to 1920x1280).

The fujifilm standard seems to be PreviewImage downscaled to 1.5 the full size as biggest jpeg.

I’ll have a better look at your resolution detail question later on.

EDIT:

@kmilos’ exiv2 command (exiv2 -pp name.raw) does what you want. Shouldn’t be to hard to create something from that:

$ exiv2 -pp fujifilm.x-t30.01.raf 
Preview 1: image/jpeg, 160x120 pixels, 8653 bytes
Preview 2: image/jpeg, 4416x2944 pixels, 5443255 bytes

EDIT2:

You can use the keyword functionality that is offered by exiftool to extract the Image Size (not the same as Raw Image Full Size):

$ exiftool "-Image*Size" fujifilm.x-t30.01.raf
Image Size                      : 4416x2944

$ exiftool "-Raw*Image*Full*Size" fujifilm.x-t30.01.raf
Raw Image Full Size             : 6384x4182

Thanks for this; much for me to explore.

You can also use exiftool -a -u -s -g1 to learn about the actual structure and contents of your camera’s raw file format (just try to understand section by section first rather than individual tags). For the Fujifilm X-T30 RAFs, it looks like you’re after PreviewImage indeed, rather than the smaller ThumbnailImage.