9

I want to convert all NEF/RAW image files to an image format that could be easily opened without additional tools.

I thought about using ImageMagick's convert tool as mentioned in How can I convert a .jpg or .png image to .raw format?

However, I don't see any parameter for recursively looking for images in all subfolders nor for removal of old/original images in the documentation of the convert tool.

Should I look for another tool, or the only option is to write some loop around convert?

matandked
  • 1,129
  • find allows you to recursively find files and folders, and offers the opportunity to execute a command on the files that were found using the -exec option. See man find to learn about the find command. You will also be able to find many examples on how to use find and its -exec and -execdir options. – vanadium May 12 '21 at 12:33

2 Answers2

21

Imagemagick cannot convert raw image files in recent Ubuntu versions because the ufraw-batch package is not available, due to it not being maintained anymore. We can however use darktable to do the conversion. To install darktable run:

sudo apt install darktable

You can then use this command that uses darktable-cli to convert the images:

find . -type f \( -iname "*.raw" -o -iname "*.nef" \) -exec sh -c 'darktable-cli {} ${0%.*}.jpg' {} \; -delete

The above command uses find to do the following:

  • recursively search in the current folder: .
  • for files only: -type f
  • that their name ends either in .raw or .nef, irrespective of their case: \( -iname "*.raw" -o -iname "*.nef" \)
  • executes (-exec) this command to convert the found files to jpg: sh -c 'darktable-cli {} ${0%.*}.jpg' {} \;
  • deletes the original files: -delete

Caution: Make sure to first test the command in a copied portion of your files to ensure that it works as intended!

  • This is a great approach. One thing though: doesn't it apply the "darktable defaults"? (which tend to be very neutral) – Daniel Oct 21 '23 at 02:35
  • @Daniel what do you mean "darktable defaults"? – BeastOfCaerbannog Oct 22 '23 at 18:58
  • 2
    I mean that, since RAW images don't contain information about how an image should "look like", darktable applies a default (quite plain) style. They generally look a bit pale and colorless, which aligns with Darktable's motto of leaving all visual choices to the user. I recommend installing/setting up a style (e.g. https://dtstyle.net/) and using the --style <style-name> option – Daniel Oct 23 '23 at 18:15
  • As @Daniel wrote, jpeg should look a bit pale and colorless… I use exiv2 -ep to extract preview pictures included in .NEF (took with Nikon Z50) as described in this post : https://discuss.pixls.us/t/rt-extracting-embedded-jpeg-from-raw-image-using-rt/28067/3 – bcag2 Dec 20 '23 at 08:43
  • I had some images with RAF file extension. I've replaced .raw with .raf and it worked. Thanks. – Caglayan DOKME Dec 23 '23 at 11:28
0

To just be able to view the files, you don't need to develop your raw image with darktable or ufraw, all common formats have an embedded preview image.

You can extract the preview with e.g. dcraw:

dcraw -e *.CR2

Or you can use a proper image viewer that will open the files and show the embdedded preview (e.g. geeqie).

pLumo
  • 26,947