Page 1 of 1

Piping from dcraw to ImageMagick?

Posted: 2019-08-12T10:08:04-07:00
by whugemann
I am using a Windows appliction that calculates luminance from RAW images taken by a calibrated camera. This application allows me to define two command lines that convert the original photo into an 8-bit-TIFF for display on the monitor and a 16-bit-TIFF for evaluation of the luminance. The default command lines that come with the application solely use dcraw for this job, i.e. allow no scaling or lens correction.

So far, I am using dcraw --> ImageMagick with an intermediate file, i.e. something along the lines of:

Code: Select all

C:\Programme\ImageMagick7\dcraw.exe -q 3 -o 0 -4 -r 1 1 1 1 -S 65535 -T -O "%~dp1temp16.TIF" %1
magick "%~dp1temp16.TIF" -scale 25%% -distort barrel "0.0099 -0.0678 0.0014 1.0511" "%~dpn1.tiff"
for the luminance and

Code: Select all

C:\Programme\ImageMagick7\dcraw.exe -q 0 -T -O "%~dp1temp.TIF" %1
magick "%~dp1temp.TIF" -scale 25%% -distort barrel "0.0099 -0.0678 0.0014 1.0511" "%~dpn1.tiff"
for the display.

This code is placed in two Windows batch files which then replace the usual dcraw-only conversion command lines -- and work just fine.

My question: Could I somehow pipe the output of dcraw into ImageMagick in order to do everything in a single command that I could provide instead of using batch files with an intermediate file?

As you can take from the above code, a solution based on the Delegates file is not suitable, as I have to adapt the dcraw options as well.

Wolfgang Hugemann

Re: Piping from dcraw to ImageMagick?

Posted: 2019-08-12T10:49:52-07:00
by snibgo
You could use the delegates.xml file, by adding two lines with special prefixes, eg "RAWMON:" and "RAWLUM".


dcraw's "-c" option sends to stdout, and this works with PNM or TIFF format:

Code: Select all

dcraw -c AGA_3443.NEF | magick PBM:- x.tiff

dcraw -c -T AGA_3443.NEF | magick TIFF:- x2.tiff

Re: Piping from dcraw to ImageMagick?

Posted: 2019-08-12T13:52:15-07:00
by whugemann
Yes, this does the trick!
But, as far as I see, only with the original version of dcraw. If I use IM's modified version (which has the additional option -O) instead, IM reports that it cannot read the input file:

Code: Select all

magick: improper image header `C:/Users/Hugemann/AppData/Local/Temp/magick-1824039DJfQo45lxb' @ error/pnm.c/ReadPNMImage/301.
The same holds for TIFF. I note this only as a warning to others. My problem is solved, as I also have the original version installed. Thanks a lot!

Re: Piping from dcraw to ImageMagick?

Posted: 2019-08-12T15:17:28-07:00
by snibgo
Which of my suggestions did you try, delegates.xml or piping? I tested the piping version with my hack of IM's modified dcraw, and it works fine.

Re: Piping from dcraw to ImageMagick?

Posted: 2019-08-13T04:12:51-07:00
by whugemann
I tried the piping version -- yesterday on my computer at home, running Windows 10, 64 bit and just now on my office computer running Windows 7, 32 bit.

The latter has just thrown a different error when using IM's version of dcraw (9.27): dcraw laments that there is 'no disk'. Again, the unmodified version (9.27ie2) of dcraw performs the same job without a problem.