problem with delegates.xml

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
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

problem with delegates.xml

Post by el_supremo »

Bonzo and I have been trying to get the dcraw8 example delegate working as described here: http://www.imagemagick.org/Usage/files/#delegate_other
but the conversion fails. IM calls dcraw with the input raw file correctly and dcraw writes to the provided temporary filename but then IM tries to open a different one.
So, I made a copy of the existing dng: delegate, removed the "-4" argument (removing this argument gives us a different type of raw photo conversion) and changed "dng" to "dcr". Now the conversion works using a command similar to "convert dcr:file.cr2 file.jpg".
But if I change "dcr" to "dcraw8" as in the example, it fails. I tried using arbitrary names and, for example, using the prefix "q" instead of "dcr" works but "qq", "qqq" and "qqqq" all fail. Typical output when it fails (in this case using the prefix cr8) is:

Code: Select all

Q:\Photos>imconvert cr8:img_1001_9398.cr2 img.jpg
Loading Canon EOS 50D image from C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-Xyutu
bj5 ...
Scaling with darkness 0, saturation 16383, and
multipliers 2.333008 1.000000 1.209961 1.000000
Converting to sRGB colorspace...
Writing data to C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-SIEg7JtK.ppm ...
imconvert: unable to open image `C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-0vnIG
odB': No such file or directory @ blob.c/OpenBlob/2482.
imconvert: unable to open module file `C:\Program Files\ImageMagick-6.5.9-Q8\mod
ules\coders\IM_MOD_RL_CR8_.dll': No such file or directory @ module.c/GetMagickM
odulePath/669.
imconvert: unable to open file `C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-0vnIGo
dB': No such file or directory @ constitute.c/ReadImage/571.
imconvert: missing an image filename `img.jpg' @ convert.c/ConvertImageCommand/2
849.
Why is it sensitive to the name?
I'm using version 6.5.9.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: problem with delegates.xml

Post by magick »

Try
  • <delegate decode="dcraw8" command="dcraw -v -w "%i" mv -f `basename "%o.ppm"` "%o""/>
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: problem with delegates.xml

Post by el_supremo »

We need something that works for Windows.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: problem with delegates.xml

Post by magick »

Ok, change the 'mv' command to rename or whatever Windows uses. We are Linux developers so we have limited knowledge about Windows.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: problem with delegates.xml

Post by el_supremo »

change the 'mv' command to rename or whatever Windows uses
Unfortunately, that's not easy. The "mv" is no problem but the backticks and the "basename" command can't be done .
But the real problem is that some delegate prefix names work whereas others don't with what is otherwise exactly the same delegate line. For example, these two versions work:

Code: Select all

<delegate decode="dcr:decode" stealth="True" command="dcraw.exe -w -O "%u.ppm" "%i""/>
<delegate decode="q:decode" stealth="True" command="dcraw.exe -w -O "%u.ppm" "%i""/>
but these two fail:

Code: Select all

<delegate decode="dcraw8:decode" stealth="True" command="dcraw.exe -w -O "%u.ppm" "%i""/>
<delegate decode="qq:decode" stealth="True" command="dcraw.exe -w -O "%u.ppm" "%i""/>
If the ":decode" is removed from the delegate name the first two still work and the other two fail.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: problem with delegates.xml

Post by magick »

Previously dcraw used to have a -O option to specify the output image filename but it was removed several releases back. An ImageMagick user contributes the dcraw program with modifications to restore the -O option so we don't need to use the equivalent of the Unix basename command.

Delegates with namespaces such as dng:decode are special delegates called internally by ImageMagick. Any delegate you create must not have namespace modifiers, just the image format name (e.g. dcraw8).

Add -verbose to your command line to help debug your delegate (e.g. convert -verbose dcraw8:IMG_2026.CR2 image.jpg).
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: problem with delegates.xml

Post by snibgo »

I know nothing about delegates, but dcraw 8.86 has option -c to write to stdout, so can you > that to %o?
snibgo's IM pages: im.snibgo.com
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: problem with delegates.xml

Post by el_supremo »

I've just installed Windows IM 6.5.9-10 and I'm still trying to get a user delegate to work.
I copied the existing dng:decode delegate, removed the -4 flag and changed the delegate name like this:

Code: Select all

<delegate decode="cr8" stealth="True" command="dcraw.exe -w -O "%o.ppm" "%i""/>
I then executed the following command to convert a Canon raw photo to an 8-bit jpg:

Code: Select all

imconvert -verbose cr8:img_1001_9399.cr2 img.jpg
The first line of output is:

Code: Select all

dcraw.exe -w -O "C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-sZ4_otv0.ppm" "C:/DOC
UME~1/ADMINI~1/LOCALS~1/Temp/magick-Swkno4GN"
which shows that the cr8: delegate is being used because otherwise there would be a "-4" flag there as well.
But the next line of the verbose output is:

Code: Select all

imconvert: unable to open image `C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-WGMzR
tpt': No such file or directory @ error/blob.c/OpenBlob/2484.
This error then causes three more errors before convert gives up.
After convert terminates, the output file magick-sZ4_otv0.ppm is still in the temporary directory and I can use convert to change this into the correct jpg.
So, the delegate is working and producing the correct output file but somehow convert is looking for a different file.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: problem with delegates.xml

Post by magick »

ImageMagick expects the delegate output file to be %o not %o.ppm.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: problem with delegates.xml

Post by el_supremo »

Sorry, I forgot to mention that I had been trying variations on the output file's name.
I tried %u.ppm as is in the original dng delegate, and I also tried %u, %o and %o.ppm.
They all fail in the same way.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Wilbert

Re: problem with delegates.xml

Post by Wilbert »

An ImageMagick user contributes the dcraw program with modifications to restore the -O option so we don't need to use the equivalent of the Unix basename command.
Are these modifications available somewhere?

Like so many people here i can't get this working on my windows machine. The included dcraw.exe (from the builds over here: ftp://ftp.imagemagick.org/pub/ImageMagick/windows) are faulty. It's says not a valid Win32 application if i click on it (both 6.5.8-5 and 6.6.2-10).

If i replace it by a working version of dcraw.exe (v9.03), and recompile. Then 'convert -verbose raw.nef test.ppm' gives the "unknown -O option" error message, as stated in the previous posts. The reason is that this option is removed in more recents builds of draw, if i understand you correctly. If i change the delegate file into:

Code: Select all

  <delegate decode="dng:decode" stealth="True" command="dcraw.exe -6 -w "%u.ppm" "%i""/>
and recompile ImageMagick, i got the same the "unknown -O option" error message. I don't understand why this error keeps coming up after changing the delegates.xml file and recompiling.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: problem with delegates.xml

Post by anthony »

In the linked IM examples area I included a -O options to specify an output file

<delegate decode="dcraw8" command='dcraw -v -w -O "%o" "%i"'>

That is probably where it is coming from. If -O is no longer valid then some other way of setting the output filename is needed.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Wilbert

Re: problem with delegates.xml

Post by Wilbert »

In the linked IM examples area I included a -O options to specify an output file

<delegate decode="dcraw8" command='dcraw -v -w -O "%o" "%i"'>

That is probably where it is coming from. If -O is no longer valid then some other way of setting the output filename is needed.
I managed to build a patched version of dcraw.exe with VC++ (and i got everything working). The patch is similar as the one from skydive.

I will include JPEG support and post the patch and my build within a few days.
Wilbert

Re: problem with delegates.xml

Post by Wilbert »

I managed to build a patched version of dcraw.exe with VC++ (and i got everything working). The patch is similar as the one from skydive.

I will include JPEG support and post the patch and my build within a few days.
Here you are (built with VC6++ and jpeg-support):

http://www.wilbertdijkhof.com/Dcraw_v903.zip

When replacing dcraw.exe from the bin folder with the one in the zip file above, recompiling ImageMagick, it all works fine. I noticed you need around 200MB of free space in your C-folder to display/convert the "bigger' raw images with ImageMagick.

I didn't include lcms support because i couldn't find pre-compiled binaries for Windows (that is for v1.x, note that for v2.x they changed their api making it unusable for dcraw), and because its support is not needed i think ???
Post Reply