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?".

problem with delegates.xml

Postby el_supremo » 2010-02-19T16:22:15+00:00

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

Re: problem with delegates.xml

Postby magick » 2010-02-19T17:07:43+00:00

Try

    <delegate decode="dcraw8" command="dcraw -v -w &quot;%i&quot; mv -f `basename &quot;%o.ppm&quot;` &quot;%o&quot;"/>
User avatar
magick
Site Admin
 
Posts: 9698
Joined: 2003-05-31T11:32:55+00:00

Re: problem with delegates.xml

Postby el_supremo » 2010-02-19T17:25:31+00:00

We need something that works for Windows.

Pete
el_supremo
 
Posts: 1027
Joined: 2005-03-21T21:16:57+00:00

Re: problem with delegates.xml

Postby magick » 2010-02-19T17:42:58+00:00

Ok, change the 'mv' command to rename or whatever Windows uses. We are Linux developers so we have limited knowledge about Windows.
User avatar
magick
Site Admin
 
Posts: 9698
Joined: 2003-05-31T11:32:55+00:00

Re: problem with delegates.xml

Postby el_supremo » 2010-02-19T18:05:42+00:00

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 &quot;%u.ppm&quot; &quot;%i&quot;"/>
<delegate decode="q:decode" stealth="True" command="dcraw.exe -w -O &quot;%u.ppm&quot; &quot;%i&quot;"/>

but these two fail:
Code: Select all
<delegate decode="dcraw8:decode" stealth="True" command="dcraw.exe -w -O &quot;%u.ppm&quot; &quot;%i&quot;"/>
<delegate decode="qq:decode" stealth="True" command="dcraw.exe -w -O &quot;%u.ppm&quot; &quot;%i&quot;"/>

If the ":decode" is removed from the delegate name the first two still work and the other two fail.

Pete
el_supremo
 
Posts: 1027
Joined: 2005-03-21T21:16:57+00:00

Re: problem with delegates.xml

Postby magick » 2010-02-19T19:24:35+00:00

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).
User avatar
magick
Site Admin
 
Posts: 9698
Joined: 2003-05-31T11:32:55+00:00

Re: problem with delegates.xml

Postby snibgo » 2010-02-19T21:35:17+00:00

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
snibgo
 
Posts: 3960
Joined: 2010-01-23T23:01:33+00:00

Re: problem with delegates.xml

Postby el_supremo » 2010-02-23T10:33:25+00:00

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 &quot;%o.ppm&quot; &quot;%i&quot;"/>

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

Re: problem with delegates.xml

Postby magick » 2010-02-23T12:05:02+00:00

ImageMagick expects the delegate output file to be %o not %o.ppm.
User avatar
magick
Site Admin
 
Posts: 9698
Joined: 2003-05-31T11:32:55+00:00

Re: problem with delegates.xml

Postby el_supremo » 2010-02-23T13:22:51+00:00

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

Re: problem with delegates.xml

Postby Wilbert » 2010-07-02T12:33:22+00:00

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 &quot;%u.ppm&quot; &quot;%i&quot;"/>


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.
Wilbert
 

Re: problem with delegates.xml

Postby anthony » 2010-07-04T23:30:26+00:00

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
http://www.imagemagick.org/Usage/
User avatar
anthony
 
Posts: 8732
Joined: 2004-05-31T19:27:03+00:00
Location: Brisbane, Australia

Re: problem with delegates.xml

Postby Wilbert » 2010-07-05T13:57:22+00:00

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

Postby Wilbert » 2010-07-11T07:29:59+00:00

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 ???
Wilbert
 


Return to Users

Who is online

Users browsing this forum: Bing [Bot], konstantin, rossdv8 and 17 guests