Linux script to automatically sort bracketed images

In a previous blog entry (Linux script to generate HDR images from bracketed images) I delivered a script to help creating HDR images out of a series of bracketed images.

But I then found myself facing another problem ... On my last vacation, I returned home with about 1500 images out of which maybe 300 where bracketed images ...
To use my tool, I would have had to manually create roughly 100 directories and figure out the series of 3 images that belonged together to isolate them in those folders ...

Instead of spending hours doing so, I decided to spend one hour writing a script that would automate this task.

So here it is !
Usage: sortBracketed.sh [OPTION] DIR
--quiet -q Quiet
--verbose -v Verbose
--dry-run -d Analyze but don't actually move the files
The script will run two passes. One for JPG files, one for CR2 files.
It checks the images three by three to make sure the numbering is continuous, that the exposure mode is bracketed and that the three images belong together because the progression of the exposure bias is consistent (0 -2 +2, -1 -2 0, etc)
When such image series are found, the script will create a sub-directory HDRx (where x is a number that is incremented automatically) and move the images there.

here's a simple example of a run:

Analyzing JPG files
Checking if file IMG_0003.JPG is bracketed ... NO
Checking if file IMG_0004.JPG is bracketed ... NO
Checking if file IMG_0005.JPG is bracketed ... NO
Checking if file IMG_0050.JPG is bracketed ... YES
Checking if file IMG_0051.JPG is bracketed ... YES
Checking if file IMG_0052.JPG is bracketed ... YES
Checking if file IMG_0053.JPG is bracketed ... YES
4 bracketed images found
Checking if images 0050 0051 0052 go together ... NO
Checking if images 0051 0052 0053 go together ... YES
IMG_0051.JPG \
IMG_0052.JPG |> HDR1 - Exposures: -1.5 0 1.5
IMG_0053.JPG /
Analyzing CR2 files
0 bracketed images found
And voilà ! I end up with a folder HDR1 containing 3 images I can use to build an HDR image.

This is the default verbosity of the output. If you pass -q as a parameter, it will be totally silent. If you pass -v, it will be even more chatty ;-)

I show here a simple example but I actually used the script on my vacation pictures and it created 93 folders and perfectly identified the series of 3 images ! Yeah me !

If you don't trust the script will work on your images, you can invoke the -d option so it will only output the information but will not create folders and move files.

You can download the script here:


sortBracketed.sh

5k


Update (29 Sept 2009): updated the script to v1.1. See changelog in the script itself.
Update (19 Mar 2010): updated the script to v1.2. See changelog in the script itself.

CC-GNU GPL
This software is licensed under the CC-GNU GPL version 2.0 or later.

Linux script to generate HDR images from bracketed images

A while ago, as I was exploring the world of HDR images and how to create them on Linux, I stumbled across the photoblog of Edu Pérez and was very interested by the workflow he used to create HDR images on Linux.
He even put most of it together in a convenient script.

Based on his work, I created my own script to align more closely to my requirements.
For instance, I happen to shoot in JPG sometimes and needed the script to support this format as well as RAW.
Moreover I also scripted the Gimp part of the workflow so the script actually generates an XCF file containing 3 layers.



  • An exposure blended image produced by enfuse as the background
  • An HDR image tone-mapped using the mantiuk06 operator in a layer in Soft-Light mode and 50% opacity
  • An HDR image tone-mapped using the fattal02 operator in a layer in Overlay mode



The script is invoked from the command-line:
Usage: createHDR.sh [OPTION] DIR
-a Align the pictures first
-g{val} gamma option for RAW conversion (--gamma={val} -- DEFAULT=0.45)
-s{val} saturation option for RAW conversion (--saturation={val} -- DEFAULT=1.0)
-e{val} exposure compensation option for RAW conversion (--exposure={val} -- DEFAULT=0.0)
-l{val} linearity option for RAW conversion (--linearity={val} -- DEFAULT=0.10)
-c{path} Configuration file for ufrraw IDFILE.ufraw
-q Quiet
-h This help

The script will make sure that only one type of file is present in the directory.

If -a is passed as an option, the script will first align the images using align_image_stack command provided by Hugin.

Here are a couple of images produced by this script out of a series of 3 bracketed images:


You can download the script here:


createHDR.sh

6k


Update (23 Sept 2009): updated the script to v1.1. See changelog in the script itself.

Update (29 Sept 2009): updated the script to v1.2. See changelog in the script itself.
Update (2 Nov 2009): updated the script to v1.3. See changelog in the script itself.
Update (12 Nov 2009): updated the script to v1.3.1. See changelog in the script itself.

CC-GNU GPL
This software is licensed under the CC-GNU GPL version 2.0 or later.