Last active
December 20, 2017 00:16
-
-
Save dbcesar/e473e85c4961d2cdb347cdd9e9c06751 to your computer and use it in GitHub Desktop.
Shell script for create batch HDR images using Luminance HDR cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# OPTIONS number of group bracket shot and verbose | |
set -e | |
INPUT_DIR="$@" | |
if [ "$#" -ne 1 ]; then | |
echo "Wrong usage" | |
echo "Usage: move_bracket_shots_and_generate_tiff.sh <INPUT_DIR>" | |
exit | |
fi | |
if [ ! -d $INPUT_DIR ]; then | |
echo "The argument must be an directory" | |
exit | |
fi | |
OUTPUT_DIR="$INPUT_DIR/exr" | |
HDR_EXTENSION=".exr" | |
mkdir -p $OUTPUT_DIR | |
BRACKET_IMAGES=3 | |
IMAGES_DIR=$(ls -l $INPUT_DIR/*.tif| grep -v ^l | wc -l) | |
#checking if number of files is compatible | |
if [ $(( $IMAGES_DIR%$BRACKET_IMAGES )) -ne 0 ]; then | |
echo "[HDR CREATOR] Number of inputs ($IMAGES_DIR) is not divisible by $BRACKET_IMAGES" | |
echo "[HDR CREATOR] Exiting the program" | |
exit | |
fi | |
declare -i i | |
i=0 | |
temp="" | |
temp_debug="" | |
for filename in $INPUT_DIR/*.tif | |
do | |
temp_debug="$temp_debug${filename##*/} " | |
temp="$temp ${filename}" | |
i=i+1 | |
if [ $(( $i%$BRACKET_IMAGES )) -eq 0 ]; then | |
filename=${temp_debug%% *} | |
filename=${filename%%.tif} | |
if [ -e $OUTPUT_DIR/$filename$HDR_EXTENSION ]; then | |
echo "File already exists" | |
else | |
echo "[HDR CREATOR] Creating HDR for the following files" | |
echo "[HDR CREATOR] $temp_debug" | |
luminance-hdr-cli $temp --save $OUTPUT_DIR/$filename$HDR_EXTENSION -a AIS | |
echo "[HDR CREATOR] output file: $OUTPUT_DIR/$filename$HDR_EXTENSION" | |
fi | |
temp="" | |
temp_debug="" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment