Converting RAW CR2 to 32bit EXR, 16bit TIFF, and 8bit JPEG

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
thwalker
Posts: 1
Joined: 2019-09-18T14:00:38-07:00
Authentication code: 1152

Converting RAW CR2 to 32bit EXR, 16bit TIFF, and 8bit JPEG

Post by thwalker »

Hi all!

I've used ImageMagick a bit in the past but I'm hitting a wall with this one. Having to dive into colorspace science a little over my head, so any help (or guidance in the proper direction) would be appreciated! Ultimately I've been tasked with converting a raw CR2 to:
  • Linear 32bit EXR and preserving the profile from the original CR2
  • LOG 16bit TIFF with the same profile
  • Normal 8bit JPEG with the same profile
I've tried both DCRAW by itself, as well as (I think) in ImageMagick. I'm using python to actual run the tests, but they're ultimately executed through command line. The below doesn't seem to actually convert as intended? At least not when we check the file in Nuke. Additionally it looks like there's some odd white balance/contrast going on in the TIFF/JPEG.

Code: Select all

magick.exe convert inFile.cr2 -depth 32 -set colorspace linear outFile.exr

The files are quite large so here's a Google Drive link to download them.
https://drive.google.com/open?id=1LrrtU ... rAylgiCM_E

Thanks! :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting RAW CR2 to 32bit EXR, 16bit TIFF, and 8bit JPEG

Post by fmw42 »

I am not an expert on CR2 files nor dcraw, but some comments are in order. I will defer to one of the ImageMagick, CR2 and EXR experts for better/correct answers.

In ImageMagick 7, use magick.exe without convert after it.

There is no colorspace called linear. If you want to convert from non-linear (sRGB) color to linear color, use -colorspace RGB.


I am not positive about this, but I think ImageMagick only can process half format (16-bit) EXR.

I do not think you can set the depth to 32 on a Q16 compiled Imagemagick.

When reading cr2 files, prepend CR2:infile.crw otherwise, you get a tiff file. See CR2 at https://imagemagick.org/script/formats.php#supported.

CR2 has white balancing and I am not sure ImageMagick can deal with that unless you set up or modify your delegates.xml file for CR2 to use the same arguments you would if you used dcraw by itself. See delegates.xml at https://imagemagick.org/script/resources.php

For LOG TIFF, you may need to use -colorspace LOG. Otherwise, -evaluate log XX. I do not think there is any direct conversion to LOG TIFF, since I know of no -define for that. See https://imagemagick.org/script/formats.php#supported for TIFF defines.

You mention profiles. But does your CR2 file have a profile. If so, you might need to extract it first and then add it to your output if the profile does not pass to it automatically.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting RAW CR2 to 32bit EXR, 16bit TIFF, and 8bit JPEG

Post by snibgo »

Your zip is too large for me to download today. Maybe at the weekend.

Different versions of IM use different delegates to demosaic raw files, and don't expose the controls from those delegates, eg white balance controls. I always use dcraw directly to create a TIFF, then do other processing with IM.

Assuming you want sRGB primaries in your output, tell dcraw to make a sRGB image, eg with "-w" to use the camera's white balance. Then use IM to "-colorspace RGB" to make it linear, or whatever you want. (As Fred says, you can modify delegates.xml to do this, eg using a different prefix for different options. But that adds an extra layer of complexity that I dislike.)
thwalker wrote:... preserving the profile from the original CR2
What profile? CR2 files do not normally have embedded ICC colour profiles, as far as I know.
snibgo's IM pages: im.snibgo.com
Post Reply