Converting raw Nikon NEF files to DNG and back on Linux
Converting raw Nikon NEF files to DNG and back on Linux
Regardless of whether it makes sense or not to convert raw files to DNG, you
might choose a middleground solution and embed the original raw file in a DNG
file.
The major drawback to this solution is that the resulting DNG file will
be roughly double in size when compared with the original raw file.
The benefit of emdedding a raw files in a DNG file that you can easily extract
it later on.
Step 1 - Install Adobe DNG Converter
You can find a very good tutorial on how to install it on Linux on RawTherapee’s website: https://rawpedia.rawtherapee.com/How_to_convert_raw_formats_to_DNG#Installing_Adobe_DNG_Converter_in_Linux
Once DNG Converter is installed, create a dng
alias to start it from CLI:
alias dng='WINEPREFIX="$HOME/WinePrefixes/DNGConverter" wine "$HOME/WinePrefixes/DNGConverter/drive_c/Program Files/Adobe/Adobe DNG Converter/Adobe DNG Converter.exe"'
Step 2 - Convert NEF files to DNG
cd
to a directory with your NEF
files and simply execute:
dng ./
It will bring the DNG Converter window up:
Click Change Preferences
and check Embed Origianal Raw File
:
Lastly, hit Convert
button and wait for the conversion to finish:
03-dng_converter_conversion_status.png
Step 3 - Extract embeded RAW NEF file from DNG
To extract an emdedded RAW NEF file from a DNG file, we’ll use the amazing ExifTool by Phil Harvey.
exiftool -b -originalrawimage DSC_0001-original.dng > DSC_0001-extracted.nef
Step 4 - Compare extracted file with the original
To ensure that both files are identicall, run a simple diff:
$ diff --report-identical-files DSC_0001-original.nef DSC_0001-extracted.nef
Files DSC_0001-original.nef and DSC_0001-extracted.nef are identical