Piping from dcraw to ImageMagick?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
whugemann
Posts: 295
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Piping from dcraw to ImageMagick?

Post by whugemann » 2019-08-12T10:08:04-07:00

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
Wolfgang Hugemann

snibgo
Posts: 12311
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Piping from dcraw to ImageMagick?

Post by snibgo » 2019-08-12T10:49:52-07:00

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
snibgo's IM pages: im.snibgo.com

User avatar
whugemann
Posts: 295
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Piping from dcraw to ImageMagick?

Post by whugemann » 2019-08-12T13:52:15-07:00

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!
Wolfgang Hugemann

snibgo
Posts: 12311
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Piping from dcraw to ImageMagick?

Post by snibgo » 2019-08-12T15:17:28-07:00

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.
snibgo's IM pages: im.snibgo.com

User avatar
whugemann
Posts: 295
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Piping from dcraw to ImageMagick?

Post by whugemann » 2019-08-13T04:12:51-07:00

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.
Wolfgang Hugemann

Post Reply