Nikon D750 .nef raw conver

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?".
snibgo
Posts: 11917
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Nikon D750 .nef raw conver

Post by snibgo » 2019-05-28T04:55:41-07:00

IM runs the delegate command, then tries to read the output from that. It expects the output from the delegate to be a file named the expansion of %o (which won't have an extension like ".tif"). So change "%u.tif" to "%o". Commands like "magick LUMINANCE:AGA_3443.NEF x.png" will then use that delegate, and work without complaint.

EDIT to add: "%u" is useful as an intermediate file when the delegate involves two or more commands, eg dcraw to write %u, then magick to read %u, process it and write %o. For example, the delegate line (for Windows)...

Code: Select all

  <delegate decode="LUM2" stealth="True" command="cmd.exe /c (F:/pictures/dcrawag.exe -q 3 -o 0 -4 -r 1 1 1 1 -S 65535 -T -O &quot;%u&quot; &quot;%i&quot;) &amp; (magick TIFF:%u -colorspace Gray -resize 600x600 %o)"/>
... means the IM command ...

Code: Select all

magick LUM2:AGA_3443.NEF x.png
... creates a small grayscale version of the input raw file.
snibgo's IM pages: im.snibgo.com

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

Re: Nikon D750 .nef raw conver

Post by whugemann » 2019-05-28T07:58:10-07:00

Although your suggestion works and solves my actual problem, I am not quite convinced: The result is pretty much the same as that of the batch file:

Code: Select all

C:\Programme\ImageMagick7\dcraw.exe -q 3 -o 0 -4 -r 1 1 1 1 -S 65535 -T -O "%~dp1temp.TIF" %1
magick "%~dp1temp.TIF" -distort barrel "0.0099 -0.0678 0.0014 1.0511" "%~dpn1.TIF"
del "%~dp1temp.TIF"
i.e. it hard-codes the conversion, whereas the intention of a delegate definition should be to define a way to turn the input file into something readable for ImageMagick – and leave me with the option to provide any command line options that come to my mind.

Or do I get something wrong?
Wolfgang Hugemann

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

Re: Nikon D750 .nef raw conver

Post by snibgo » 2019-05-28T08:59:52-07:00

whugemann wrote:... and leave me with the option to provide any command line options that come to my mind.
IM has no mechanism for taking arbitrary options from its command line and passing those to the delegate.

That's one reason why I don't use IM to call dcraw to read raw files. Instead, I use dcraw directly.
snibgo's IM pages: im.snibgo.com

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

Re: Nikon D750 .nef raw conver

Post by whugemann » 2019-05-28T12:03:43-07:00

IM has no mechanism for taking arbitrary options from its command line and passing those to the delegate.
I don't want to pass parameters to the delegate; I would like to be to be free of choice in regard to the operations that magick performs on the temporary file, for example scaling, a 3x3 median, embed a logo or apply a false colour palette.
Wolfgang Hugemann

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

Re: Nikon D750 .nef raw conver

Post by snibgo » 2019-05-28T12:12:17-07:00

Sorry, I don't understand your question.

IM calls the delegate and reads the result into memory. Then IM can do any command line options, such as "-flip -flop" and write the image to a file:

Code: Select all

magick LUM2:AGA_3443.NEF -flip -flop x.png
snibgo's IM pages: im.snibgo.com

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

Re: Nikon D750 .nef raw conver

Post by whugemann » 2019-05-28T13:13:35-07:00

I think our misunderstanding arises from the point that your suggested delegate-command

Code: Select all

<delegate decode="LUM2" stealth="True" command="cmd.exe /c (F:/pictures/dcrawag.exe -q 3 -o 0 -4 -r 1 1 1 1 -S 65535 -T -O &quot;%u&quot; &quot;%i&quot;) &amp; (magick TIFF:%u -colorspace Gray -resize 600x600 %o)"/>
performs the entire job on its own. I now tried

Code: Select all

<delegate decode="LUM2" stealth="True" command="dcraw.exe -q 3 -r 1 1 1 1 -T -O &quot;%o&quot; &quot;%i&quot;"/>
and found that working as you said. I see: Most entries in delegates.xml use %o as the pivot (i.e. intermediate format), whereas the (superfluous) dng-delegate-entry is

Code: Select all

<delegate decode="dng:decode" stealth="True" command="dcraw.exe -6 -W -O &quot;%u.ppm&quot; &quot;%i&quot;"/>
using %u.ppm as the pivot.

As I understand %o, it would mean that if you convert to a lossy format such as JPEG in the end, the intermediate file would also be JPEG, i.e. causing two lossy compressions (?).

Does

Code: Select all

decode="dng:decode"
have any special meaning in comparison to just

Code: Select all

decode="dng"
?
Wolfgang Hugemann

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

Re: Nikon D750 .nef raw conver

Post by snibgo » 2019-05-28T14:03:26-07:00

whugemann wrote:I think our misunderstanding arises from the point that your suggested delegate-command ...
I invented an example to show the use of %u as in intermediate file in a delegate that used two commands. The commands I used were not important. You need only one command, so don't need to use %u. Sorry if I confused you.
whugemann wrote:As I understand %o, it would mean that if you convert to a lossy format such as JPEG in the end, the intermediate file would also be JPEG, i.e. causing two lossy compressions (?).
At the end of the IM command, you might write the image to JPEG or any other format. That has no effect on what happens within the delegate.

I don't know the difference (if any) between ...

Code: Select all

decode="dng:decode"
... and ...

Code: Select all

decode="dng"
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 25266
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Nikon D750 .nef raw conver

Post by fmw42 » 2019-05-28T16:26:05-07:00

See https://imagemagick.org/script/formats.php

It says:
DNG R Digital Negative Requires an explicit image format otherwise the image is interpreted as a TIFF image (e.g. dng:image.dng).

Post Reply