#!/bin/bash## Bashfuse v0.2## Copyright (C) 2008 - Frederic Mantegazza## This script calls tufuse.exe through wine to fuse the input images.# The number of images per group is asked via Xdialog. Then each group# is fused, procssing them in the order that they were passed to the# script.## For example, if you bracketed -2, 0 and +2, then the number of images# per group is 3, and the images are img1.tif img2.tif img3.tif# img4.tif img5.tif img6.tif etc... The first group to be processed contains# img1.tif img2.tif and img3.tif, second group process img3.tif img4.tif# and img5.tif, and so on for all your images.## For each group, the output name is computed using the first image name# of the group. The extension (.tif in our example) is removed, and the suffix# _tufuse.tif is added. If it already exists, an increment is used,# e.g. img1_tufuse_1.tif.## This script can be called from gqview. To set it up, go to# Preferences > Editors, in an empty "Menu name" field enter:# tufuse# and in the "Command Line" field enter:# %v/path/to/tufuse.sh %f# e.g. %v/home/user/tufuse.sh %f## The %v is optional but recommended as it will show you what's happening# while processing. Note: there is no space between %v and the path.## This script depends on Xdialog to let you choose number of photos per group:# http://xdialog.free.fr/## on WINE to run tufuse.exe:# http://www.winehq.org/## You need the Windows version of DCRaw to be able to process non-tiff# files:# http://www.lebsanft.org/blog/?tag=dcraw## as well as the cygwin.dll files, also available on the above website, to be# able to run dcraw.exe:# http://www.lebsanft.org/files/cygwin.tar.gz## IMPORTANT: keep tufuse.sh (this script), tufuse.exe, dcraw.exe and the# cygwin files in the same directory!# e.g. /home/user/#'export WINEDEBUG="warn-all,err-all,fixme-all"#Set the path to your tufuse.exe fileTUFUSE_PROG="wine /home/drslony/tufuse.exe"# Set your tufuse.exe parameters. Check the tufuse website for the full list# and explanation.# Current settings output 16bit tiff files using deflate compressionTUFUSE_PARAMS=(-a 16 --compression DEFLATE)# Functions#processGroup(){ echo Processing "$@" base="${1%.*}" output="$base"_tufuse.tif index2=1 if [ -e "$output" ]; then output="$base"_tufuse_$index2.tif while [ -e "$output" ]; do index2=$((index2 + 1)) output="$base"_tufuse_$index2.tif done fi $TUFUSE_PROG -o "$output" ${TUFUSE_PARAMS[@]} "$@"}process(){ # tufuse.exe expects source images in the current dir dir=`dirname "$1"` #if input files (first input file) are not tiff then copy dcraw files to photo dir and delete them once tufusing is complete if [[ $1 != *.tif ]]; then cp dcraw.exe cygwin1.dll cyglcms-1.dll cygjpeg-62.dll "$dir"\/ trap "rm \"$dir/dcraw.exe\" \"$dir/cygwin1.dll\" \"$dir/cyglcms-1.dll\" \"$dir/cygjpeg-62.dll\"" 0 fi cd "$dir" # Initial params nbGroups=$(($# / nbImgPerGrp)) echo nbGroups=$nbGroups nbImages=$((nbGroups * nbImgPerGrp)) echo nbImages=$nbImages if [ $# -ne $nbImages ]; then echo "Error: the number of images ($#) is not a multiple of the number of images per group ($nbImgPerGrp)" exit 1 fi # Create groups index=0 group=() for file in "$@"; do group=("${group[@]}" "$(basename "$file")") if (( "${#group[@]}" == nbImgPerGrp )); then processGroup "${group[@]}"; group=(); fi; done;}# Main script## Ask for settingsnbImgPerGrp=`Xdialog --title "# per bracket" --stdout --spinbox "How many images per group?" 0 0 2 012 3 ""`ret=$?case $ret in 0) process "$@";; 1) echo "Canceled";; 255) echo "Aborted";;esac