imagemagick RAW file identify/convert - no such file or directory (tmp file)

2.4k views Asked by At

I'm trying to use imagemagick-7 (CLI) on ubuntu to identify and convert RAW images to PNG format. I am using the dcraw binary as the delegate for identifying and converting raw images.

I updated the dng:decode delegate in delegates.xml as follows:

<delegate decode="dng:decode" command="&quot;dcraw&quot; &quot;%i&quot;" />

When I run this command: magick identify test.dng, I get the following error:

identify: unable to open image '/tmp/magick-24332a6nW8lcwejNJ.ppm': No such file or directory @ error/blob.c/OpenBlob/3489.

The same error is given for magick convert. I noticed that imagemagick is generating a temporary intermediate file in my /tmp directory, which has a different name than the name it's expecting to find there. For example, it generates this file - magick-24332P6aVDePOFeCn.ppm - but is expecting the file it generated to have this name - magick-24332a6nW8lcwejNJ.ppm - which is why it's not finding it.

Note: I tested the same thing on OS X and it works perfectly fine (with the same delegates.xml configuration).

Is this a bug in imagemagick's implementation for unix systems or am I doing something wrong? Any thoughts would be greatly appreciated!

3

There are 3 answers

0
corecase On

For anyone else who experiences this problem, my solution ended up being to switch from imagemagick to graphicsmagick, which is by default configured to use dcraw (of course, you need to have dcraw installed and on your PATH).

http://www.graphicsmagick.org/

0
vincent baronnet On

You were close the right command to use in delegate is

<delegate decode="dng:decode" command="&quot;dcraw&quot; -c &quot;%i&quot; &gt; &quot;%u.ppm&quot;" />
6
emcconville On

Almost! You need to use the %o placeholder to tell the delegate manager were the output file will be written to. However the dcraw utility doesn't have in output destination options -- at least from what I can tell form the man-page. It does have a stdout option (-c), so you should be able to pipe/redirect the stream to an output location.

dcraw -c %i > %o

or in delegate XML.

<delegate decode="dng:decode" command="&quot;dcraw&quot; -c &quot;%i&quot; &gt; &quot;%o&quot;" />

Update

Some tricks I've observed with custom delegations.

  • Use full path to binaries. Usually because I installed something outside of the systems PATH. Usually /usr/local/bin or /opt directories.

    command="/usr/local/bin/dcraw ...
    
  • Use mv over pipes. If your not comfortable with debugging unix streams & such. Just do some basic copy/move command. We can rewrite the above command with something like...

    dcraw %i; mv %i.ppm %o
    
  • Ignore escaping quotes until you know its working. Encapsulating arguments are important, and keep everything safe, but \"%i & &quot;%i are hard to read.

    <delegate decode="dng:decode" command="dcraw %i; mv %i.ppm %o" />
    

    ... verify things are called correctly ... then probably escape paths.

    <delegate decode="dng:decode" command="dcraw &quot;%i&quot;; mv &quot;%i&quot;.ppm &quot;%o&quot;" />
    
  • As pointed out previously, use identify -list Delegate to verify that the command is loaded correctly, and -verbose to verify that it was called correctly during runtime.