How To: Automate HDR on Linux - Part 2

The next step in the procedure is to generate an HDR format image for each set of 5 images that we organized in Part 1. This part of the series is really very simple. There’s just one simple script to run in each directory that was created in the first part. Don’t worry, at the end of the series we’ll be wrapping it all up with a script to handle stepping through each directory.

Using this script is really easy, you just run it in a directory that contains your bracketed images. Then it creates a couple of .exr files for you. One is a full size, and one is a smaller version. You can control the size of the small version by editing the THUMBSIZE variable in the script. You may also tweak the GAUSS variable to control how pfshdrcalibrate handles your particular images.

There are two versions of the scrip here.  One for JPEG files and one for NEF files.

Download make_exr_b_jpeg.sh

#!/bin/bash
################################
# Written by Jeremy Green
# http://www.rhythmandcode.com/
################################

THUMBNAILS=true
THUMBSIZE=1536
GAUSS=8
LONGDIR=$(pwd)
DIR=${LONGDIR##*/}

#first convert all filenames to lower case
for file in `ls *NEF`
	do
	newname=`echo $file | tr [A-Z] [a-z]`
	mv -u -f $file $newname.tmp
	mv -u -f $newname.tmp $newname
done

if [ -f $DIR.hdrgen ]; then
    echo "do nothing... remove $DIR.hdrgen to regenerate"
else
    echo "dcraw2hdrgen *.nef > $DIR.hdrgen"
    dcraw2hdrgen *.nef > $DIR.hdrgen
fi

if [ -f $DIR.full.exr ]; then
    #do nothing
    echo "do nothing... remove $DIR.full.exr to regenerate"
else
    echo "pfsinhdrgen $DIR.hdrgen | pfshdrcalibrate -v -b 16 -g $GAUSS -r linear -c none | pfsoutexr --fix-halfmax $DIR.full.exr"
          pfsinhdrgen $DIR.hdrgen | pfshdrcalibrate -v -b 16 -g $GAUSS -r linear -c none | pfsoutexr --fix-halfmax $DIR.full.exr
fi

if [ -f $DIR.thumb.exr ]; then
    #do nothing
    echo "do nothing... remove $DIR.thumb.exr to regenerate"
else
    echo "pfsin $DIR.full.exr | pfssize --maxx $THUMBSIZE --maxy $THUMBSIZE | pfsout --fix-halfmax $DIR.thumb.exr"
    pfsin $DIR.full.exr | pfssize --maxx $THUMBSIZE --maxy $THUMBSIZE | pfsout --fix-halfmax $DIR.thumb.exr
fi

Downoad make_exr_b_nef.sh

#!/bin/bash
################################
# Written by Jeremy Green
# http://www.rhythmandcode.com/
################################

THUMBNAILS=true
THUMBSIZE=1536
GAUSS=8
LONGDIR=$(pwd)
DIR=${LONGDIR##*/}

#first convert all filenames to lower case
for file in `ls *NEF`
	do
	newname=`echo $file | tr [A-Z] [a-z]`
	mv -u -f $file $newname.tmp
	mv -u -f $newname.tmp $newname
done

if [ -f $DIR.hdrgen ]; then
    echo "do nothing... remove $DIR.hdrgen to regenerate"
else
    echo "dcraw2hdrgen *.nef > $DIR.hdrgen"
    dcraw2hdrgen *.nef > $DIR.hdrgen
fi

if [ -f $DIR.full.exr ]; then
    #do nothing
    echo "do nothing... remove $DIR.full.exr to regenerate"
else
    echo "pfsinhdrgen $DIR.hdrgen | pfshdrcalibrate -v -b 16 -g $GAUSS -r linear -c none | pfsoutexr --fix-halfmax $DIR.full.exr"
          pfsinhdrgen $DIR.hdrgen | pfshdrcalibrate -v -b 16 -g $GAUSS -r linear -c none | pfsoutexr --fix-halfmax $DIR.full.exr
fi

if [ -f $DIR.thumb.exr ]; then
    #do nothing
    echo "do nothing... remove $DIR.thumb.exr to regenerate"
else
    echo "pfsin $DIR.full.exr | pfssize --maxx $THUMBSIZE --maxy $THUMBSIZE | pfsout --fix-halfmax $DIR.thumb.exr"
    pfsin $DIR.full.exr | pfssize --maxx $THUMBSIZE --maxy $THUMBSIZE | pfsout --fix-halfmax $DIR.thumb.exr
fi

Leave a Reply