How can I batch-convert a Canon CR2 into multiple exposure-shifted TIFFs from the command line on macOS?

Asked 5/20/2013

4 views

2 answers

0

I want to take a single Canon RAW file (CR2) and generate 2–3 or more TIFFs at different exposure levels for pseudo-HDR/tonemapping, using the command line on macOS. Apple’s sips doesn’t appear to offer an exposure adjustment for RAW conversion. Is dcraw a workable option for this, and if so, what settings or workflow should I use to create multiple exposure-variant TIFFs from one RAW file?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

13y ago

2 Answers

5

If you are interested in this, I would suggest getting 'dcraw' which is a command line RAW converter. There is a Mac version for download from the site, the source code, and if you have HomeBrew installed, you can install it via 'brew install dcraw'.

The 'dcraw' program allows you to specify a variety of options including the Gamma and Exposure level settings to apply to the output file.

I've used it for this purpose before, to "convince" the HDR merge programs to make use of the information. Note it will probably take some messing around.

http://www.cybercom.net/~dcoffin/dcraw/

I use the '-b' option:

rawfile=<your raw file name>
for b in 0.25 0.50 1.00 2.00 4.00 8.00
do
   dcraw  -T -4 -v -w -W -b ${b} $rawfile
   mv ${rawfile}.tiff ${rawfile}-b${b}.tiff
done

This will create a series of TIFF images with varying levels of brightness as well as being 16bit linear Tiffs. (Gamma=1)

You can then merge these images in an HDR program to take advantage of the lightened shadows and darkened highlights.

dcraw also has a highlight recovery option:

-H [0-9]  Highlight mode (0=clip, 1=unclip, 2=blend, 3+=rebuild)

which can be applied to the raw processing.

To "assist" the HDR merge program(s), you will then also need to adjust the exposure settings in the EXIF meta embedded in the TIFF files generated. The easiest would be to change the ISO value.

So, for where b=1.0, which is the normal:

exiftool -ISO <filename where b=1.0>

This should tell you the ISO value.

For the other images, you will want to change the ISO value to reflect an effective EV change:

b8.00 = ISO * 8
b4.00 = ISO * 4
b2.00 = ISO * 2
b0.50 = ISO/2
b0.25 = ISO/4

(Someone correct me if I'm wrong on the EV/ISO values).

So let's say the ISO was 100 for b1.0:

exiftool -ISO=25 <filename where b=0.25>
exiftool -ISO=50 <filename where b=0.50>
exiftool -ISO=200 <filename where b=2.0>
exiftool -ISO=400 <filename where b=4.0>
exiftool -ISO=800 <filename where b=8.0>

This way, the images will be recognized as being part of different exposure ranges.

Note, the brightness doesn't translate directly into EV steps, but this will allow the merge program to put the images in the general ballpark of where the images would be given the change in effective brightness.

Originally by user19243. Source · Licensed CC BY-SA 4.0

user19243

13y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Yes. dcraw is the relevant command-line tool for this job, and it can output TIFFs while applying exposure scaling. The community answer suggests using the -b brightness option to create multiple versions from one CR2, then feeding those TIFFs into your HDR/tonemapping software.

Example workflow:

rawfile=yourfile.CR2
for b in 0.25 0.50 1.00 2.00 4.00 8.00
do
  dcraw -T -4 -v -w -W -b ${b} "$rawfile"
  mv "${rawfile}.tiff" "${rawfile}-b${b}.tiff"
done

Common flags shown here:

  • -T output TIFF
  • -4 linear 16-bit output
  • -w use camera white balance
  • -W avoid automatic brightening
  • -b set brightness/exposure scale

This is a practical way to generate pseudo-bracketed TIFFs from a single RAW, though you may need to experiment with the -b values to suit your HDR software. Another community suggestion was ImageMagick, but for RAW development itself, dcraw is the more direct fit.

UniqueBot

AI

13y ago

Your Answer