Converting CR2 fails

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
martinho
Posts: 5
Joined: 2015-12-01T07:28:51-07:00
Authentication code: 1151

Converting CR2 fails

Post by martinho »

Hi,

When trying to convert CR2 to PNG, I get the following error:

Code: Select all

"ImageMagick execution failed: 'convert.exe: FailedToExecuteCommand `dcraw.exe -6 -W -O \"magick-43188phP2-I6ejfcJ.ppm\" \"magick-43188t9WLd2cunaon\"' (-1073741819) @ error/delegate.c/ExternalDelegateCommand/463.
convert.exe: DelegateFailed `dcraw.exe -6 -W -O \"%u.ppm\" \"%i\"' @ error/delegate.c/InvokeDelegate/1845.
convert.exe: UnableToOpenBlob 'magick-43188phP2-I6ejfcJ.ppm': No such file or directory @ error/blob.c/OpenBlob/2695.
convert.exe: NoImagesDefined `D:\\temp\\m\\67\\50\\67508c75c99a44a58ac17417787992f3\\1334012583_-mg-9952.jpg' @ error/convert.c/ConvertImageCommand/3253.'"
I've done some additional tests with multiple versions of IM to convert CR2 files. The issue seems to happen for any CR2 file.

ImageMagick-6.9.1-2-Q16: Is able to convert the image, no error
ImageMagick-7.0.2-Q16: Fails, same error
ImageMagick-7.0.6-Q16: Fails, same error

It seems the issue is related to the installed dcraw.exe version that comes with the IM installation. IM uses dcraw to convert RAW files (Canon, Nikon, ...) and calls it as a delegate to do a "pre-conversion" of the file.

Code: Select all

//6.9.1-2 version
dcraw -v z:\share\TestFiles\1334012583_-mg-9952.CR2
Loading Canon EOS 5D image from z:\share\TestFiles\1334012583_-mg-9952.CR2 .
..
Scaling with darkness 128, saturation 3692, and
multipliers 2.395443 1.000000 1.253807 1.000000
AHD interpolation...
Converting to sRGB colorspace...
Writing data to z:\share\TestFiles\1334012583_-mg-9952.ppm ...

//7.0.2 & 7.0.6 version
dcraw -v z:\share\TestFiles\1334012583_-mg-9952.CR2
Loading Canon EOS 5D image from z:\share\TestFiles\1334012583_-mg-9952.CR2 .
..
Scaling with darkness 128, saturation 3692, and
multipliers 2.395443 1.000000 1.253807 1.000000
AHD interpolation...
Converting to sRGB colorspace...
CRASH
Installed DCRAW.exe versions are:
  • ImageMagick-6.9.1-2-Q16: v9.19
  • ImageMagick-7.0.2-Q16: v9.27
  • ImageMagick-7.0.6-Q16: v9.27
I'd really appreciate any help.

Thanks!
Maarten
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting CR2 fails

Post by snibgo »

What platform are you on? How are you running IM's convert?

The message "convert.exe: FailedToExecuteCommand ..." comes from IM, but this is wrapped in text "ImageMagick execution failed:" which isn't from IM.

Code: Select all

-O \"magick-43188phP2-I6ejfcJ.ppm\"
This tells dcraw to write the output to the root directory, which is very unusual (and a bad idea). This would normally be a temp directory, %TEMP% on windows or /tmp on unix.

So this might be a permissions problem, with access to the root directory. Or it might be a permissions problem on the dcraw program.

It might be a problem in your policy.xml file. Check that it allows images of the size (width, height and area) of your CR2.
snibgo's IM pages: im.snibgo.com
martinho
Posts: 5
Joined: 2015-12-01T07:28:51-07:00
Authentication code: 1151

Re: Converting CR2 fails

Post by martinho »

Running this command

Code: Select all

convert.exe -verbose "C:\temp\test.CR2" "C\temp\test.png"
as Administrator on my local Windows machine results in

Code: Select all

dcraw.exe -6 -W -O "C:/Users/mv/AppData/Local/Temp/magick-3332yhuwfb9FpKVo.ppm" "C:/Users/mv/AppData/Local/Temp/magick-3332pIDmaXA3Xbt1"
C:/Users/mv/AppData/Local/Temp/magick-3332yhuwfb9FpKVo.ppm PPM 4386x2920 4386x2920+0+0 16-bit sRGB 73.2829MiB 0.094u 0:00.093
C:\temp\test.CR2=>C:/Users/mv/AppData/Local/Temp/magick-3332yhuwfb9FpKVo.ppm CR2 4386x2920 4386x2920+0+0 16-bit sRGB 73.2829MiB 0.016u 0:00.016
C:\temp\test.CR2=>C\temp\test.png CR2 4386x2920 4386x2920+0+0 16-bit sRGB 73.2829MiB 0.094u 0:00.108
convert.exe: unable to open image 'C\temp\test.png': No such file or directory @ error/blob.c/OpenBlob/3093.
convert.exe: WriteBlob Failed `C\temp\test.png' @ error/png.c/MagickPNGErrorHandler/1666.
I would be surprised if this is permission related. The error occurs when using ImageMagick-7.0.6-Q16 which comes with dcraw.exe version 9.27.

When using ImageMagick-7.0.4-Q16 which also comes with dcraw.exe 9.27 I did not encounter any issues.

Policy.xml files are identical for both versions.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policymap [
<!ELEMENT policymap (policy)+>
<!ELEMENT policy (#PCDATA)>
<!ATTLIST policy domain (delegate|coder|filter|path|resource) #IMPLIED>
<!ATTLIST policy name CDATA #IMPLIED>
<!ATTLIST policy rights CDATA #IMPLIED>
<!ATTLIST policy pattern CDATA #IMPLIED>
<!ATTLIST policy value CDATA #IMPLIED>
]>

<policymap>
  <policy domain="cache" name="shared-secret" value="passphrase" stealth="true"/>
</policymap>
Any ideas? Thanks!
Maarten
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting CR2 fails

Post by snibgo »

What happens when you run dcraw directly, eg:

Code: Select all

dcraw -6 -W -O abc.ppm C:\temp\test.CR2
snibgo's IM pages: im.snibgo.com
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Converting CR2 fails

Post by GeeMack »

martinho wrote: 2017-06-27T05:42:12-07:00Any ideas? Thanks!
One line of the error you posted is this...

Code: Select all

convert.exe: unable to open image 'C\temp\test.png': No such file or directory @ error/blob.c/OpenBlob/3093.
There is a missing colon ":" after the drive letter in the drive:path part of that. I haven't looked at anything else in the error, but it seems IM is unlikely to find and process an image without a valid path.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting CR2 fails

Post by snibgo »

Well spotted, GeeMack. Yes, that explains the problem.
snibgo's IM pages: im.snibgo.com
martinho
Posts: 5
Joined: 2015-12-01T07:28:51-07:00
Authentication code: 1151

Re: Converting CR2 fails

Post by martinho »

GeeMack wrote: 2017-06-27T06:35:14-07:00 There is a missing colon ":" after the drive letter in the drive:path part of that. I haven't looked at anything else in the error, but it seems IM is unlikely to find and process an image without a valid path.
Indeed, good catch! :-) However, without typo I still end up with a 'NoImagesDefined' exception like mentioned in my initial post.
snibgo wrote: 2017-06-27T06:26:48-07:00 What happens when you run dcraw directly, eg:

Code: Select all

dcraw -6 -W -O abc.ppm C:\temp\test.CR2
abc.ppm: Permission denied
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting CR2 fails

Post by snibgo »

martinho wrote:abc.ppm: Permission denied
Okay, that's a more fundamental problem. The OS is denying dcraw permission to write to the current directory. I expect this will also fail:

Code: Select all

echo Hello >junk.txt
If the echo works, then I suspect a bug in dcraw. Try this:

Code: Select all

dcraw -6 -W C:\temp\test.CR2 >abc.ppm
But if echo doesn't work, then you need to change permissions on your directory, or change to a directory that has permissions.
snibgo's IM pages: im.snibgo.com
martinho
Posts: 5
Joined: 2015-12-01T07:28:51-07:00
Authentication code: 1151

Re: Converting CR2 fails

Post by martinho »

That works, seems to be a permission issue after all. Thanks for the help, much appreciated!
Post Reply