Convert of CR2 or ORF comes out black

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
cyrusmcrae
Posts: 8
Joined: 2016-11-08T08:08:12-07:00
Authentication code: 1151

Convert of CR2 or ORF comes out black

Post by cyrusmcrae »

I just installed ImageMagick on windows 10, including the 'legacy convert' option. When I open a CR2 or ORF (raw files from Canon or Olympus) in IMdisplay or if I use 'convert' or 'magick convert' at the command line, I get a pure black image (of the dimensions of the input image).

Eg., here's a command lines I tried:

magick convert CR2:filename.CR2 output.jpg

(outputs of 'png' or 'win:' also come out black)

Other conversions not involving those raw file types work (but I want to work with raw files).

Any ideas what I could be doing wrong?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert of CR2 or ORF comes out black

Post by snibgo »

Please say what version IM you are using.

There have been reports of this happening, caused by a buggy "improvement" to the IM version of dcraw.exe.

As such, I'm moving this to the bugs forum. With luck, a developer will respond.
snibgo's IM pages: im.snibgo.com
cyrusmcrae
Posts: 8
Joined: 2016-11-08T08:08:12-07:00
Authentication code: 1151

Re: Convert of CR2 or ORF comes out black

Post by cyrusmcrae »

Here's the output of 'convert -version':

Version: ImageMagick 7.0.3-5 Q16 x64 2016-10-31 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

ps., a DNG version (created by Adobe's converter) of my ORF also came out black.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Convert of CR2 or ORF comes out black

Post by dlemstra »

Can you share an input image I can use to reproduce the issue?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
cyrusmcrae
Posts: 8
Joined: 2016-11-08T08:08:12-07:00
Authentication code: 1151

Re: Convert of CR2 or ORF comes out black

Post by cyrusmcrae »

Here's the URL for an ORF raw file from the dpReview sample web site: goo.gl/Egwmoh

You should get a download of a file called PA271446.ORF

When I download it and use 'convert PA271446.ORF abc.jpg', I get abc.jpg as a black file with the same dimensions as the ORF.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Convert of CR2 or ORF comes out black

Post by dlemstra »

It appears that the request has expired?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
cyrusmcrae
Posts: 8
Joined: 2016-11-08T08:08:12-07:00
Authentication code: 1151

Re: Convert of CR2 or ORF comes out black

Post by cyrusmcrae »

Sorry. Hey, I noticed that they provide a direct URL -- try this:

https://www.dpreview.com/sample-galleri ... 6876240188

Once there, look for 'RAW' and click on that to download the image.

(I had picked that image 'randomly', downloaded it, and confirmed that it generated a black image.)


If the above link doesn't work, it can be reached 'manually' this way:

Go to https://www.dpreview.com/samples/119575 ... le-gallery
then go to image 19 (of 52), a photo of some basalt columns at a beach.
cyrusmcrae
Posts: 8
Joined: 2016-11-08T08:08:12-07:00
Authentication code: 1151

Re: Convert of CR2 or ORF comes out black

Post by cyrusmcrae »

This bug is still present in the latest release (7.0.3-9 Q16 x64 2016-12-05). Most recently, I tested it by trying to open a Canon CR2 raw file and got black.

Has anyone else been able to reproduce it? Or is it just my system.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert of CR2 or ORF comes out black

Post by snibgo »

The "black output from IM's dcraw" bug wasn't present in IM v7.0.3-6.

You might want to check that you don't have other versions of dcraw lying around.
snibgo's IM pages: im.snibgo.com
cyrusmcrae
Posts: 8
Joined: 2016-11-08T08:08:12-07:00
Authentication code: 1151

Re: Convert of CR2 or ORF comes out black

Post by cyrusmcrae »

Thanks for your post.

I did a search using 'File Explorer' on C:\ for dcraw and found only the one in ImageMagick. Also I did a 'where' and 'version':

C:\>where dcraw
C:\Program Files\ImageMagick-7.0.3-Q16\dcraw.exe

C:\>"Program Files\ImageMagick-7.0.3-Q16\convert.exe" -version
Version: ImageMagick 7.0.3-9 Q16 x64 2016-12-05 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

(I did an uninstall, re-download, and re-install prior to the above, selecting the defaults plus 'legacy' to get convert.)

Then I downloaded a sample CR2 raw file from http://www.rawsamples.ch/raws/canon/RAW ... S_600D.CR2, started ImageMagick Display (IMDisplay), File->Open (All files) and opened that file. After a couple of seconds (suggesting dcraw was running), the image opened -- solid black.

If I try to use that dcraw directly ('dcraw filename.cr2'), I get an 'invalid argument' error prefixed with garbage characters (I gather that dcraw has been modified to work with IM).

Is there a way for me to test that dcraw directly? (is there something I can add to the command line to get past that 'invalid argument'?)

Is there a command-line IM command I could try (maybe IMDisplay is the problem?)?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert of CR2 or ORF comes out black

Post by snibgo »

I don't know why the IM version of dcraw gives "invalid argument". The IM version was once identical to Dave Coffin's source, except for the useful addition of the "-O" option.

This works fine for me, where %IMG7% is the directory that contains my 7.0.3-6 IM installation:

Code: Select all

%IMG7%dcraw -6 -T -v -O x.tiff RAW_CANON_EOS_600D.CR2
snibgo's IM pages: im.snibgo.com
cyrusmcrae
Posts: 8
Joined: 2016-11-08T08:08:12-07:00
Authentication code: 1151

Re: Convert of CR2 or ORF comes out black

Post by cyrusmcrae »

Interesting. When I do the command you suggested:

C:\Program Files\ImageMagick-7.0.3-Q16>.\dcraw.exe -6 -T -v -O c:\x.tiff c:\RAW_CANON_EOS_600D.CR2
Loading Canon EOS 600D image from c:\RAW_CANON_EOS_600D.CR2 ...
Platform 0: Advanced Micro Devices, Inc. OpenCL 2.0 AMD-APP (1800.11)
Device 0: Cedar <---
Scaling with darkness 2048, saturation 13584, and
multipliers 2.500482 1.000000 1.401827 1.000000
AHD interpolation (CL)...
Converting to sRGB colorspace...
Writing data to c:\x.tiff ...

I get a black rectangle.

However, when I install on two different machines (physical Win10 and virtual Win7), I get a proper image.

When I download (http://axelriet.blogspot.ca/2009/01/rea ... 90121.html) and run dcraw (renamed to xdcraw just to be sure I'm getting the right one):

>.\xdcraw-9.27-ms-64-bit.exe -6 -T -v c:\RAW_CANON_EOS_600D.CR2
Loading Canon EOS 600D image from c:\RAW_CANON_EOS_600D.CR2 ...
Scaling with darkness 2048, saturation 13584, and
multipliers 2.500482 1.000000 1.401827 1.000000
AHD interpolation...
Converting to sRGB colorspace...
Writing data to c:\RAW_CANON_EOS_600D.tiff ...

I get a TIFF of flowers.

So, apparently something about my machine is messing up IM's version of dcraw.

(Thanks for the -O tip!)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert of CR2 or ORF comes out black

Post by snibgo »

Your failure case "-v" shows that OpenCL is being used, but your success case shows it isn't. The "black image" bug started appearing when OpenCL was added to dcraw. It now seems to have been cured for my machine, with Intel CPU and graphics card. But perhaps it hasn't for your AMD and "Cedar" (whatever that is).

My verbose output is:

Code: Select all

Loading Canon EOS 600D image from RAW_CANON_EOS_600D.CR2 ...
Platform 0: Intel(R) Corporation OpenCL 1.2
        Device 0: Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz
        Device 1: Intel(R) HD Graphics 4600  <---
Scaling with darkness 2048, saturation 13584, and
multipliers 2.500482 1.000000 1.401827 1.000000
AHD interpolation (CL)...
Converting to sRGB colorspace...
Writing data to x.tiff ...
snibgo's IM pages: im.snibgo.com
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Convert of CR2 or ORF comes out black

Post by dlemstra »

The next version of IM will not use the OpenCL dcraw version under Windows. You will need to compile IM with OpenCL support to get this feature.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert of CR2 or ORF comes out black

Post by snibgo »

How about instead adding a run-time option to use OpenCL, or not to use it? Then it's available for the machines it works on. It also gives a diagnostic tool.
snibgo's IM pages: im.snibgo.com
Post Reply