Bash Enfuse v0.1
This script will allow you to easily batch Enfuse images in Linux. Enfuse lets you blend different exposures of the same scene, as well as to merge several photos of the same scene with different focused areas into one well-focused image. To learn more about Enfuse, visit the official Enblend website as well as the Panotools Enfuse wiki.
Dependencies
Well you obviously need Enfuse, so either get it from the official Enblend website or from your package management system. You need to download Enblend-3.2 or higher, Enfuse comes bundled with it. This script also relies on Xdialog and Beep to run. You can remove the beep part from the code but then you won't get any audio response upon enfuse completion.
Tweak the script
Copy the script below and save it as a file with a .sh extension, e.g.
You will want to tweak this script to your system specs before using it. Line 70 sets the value of -m to 1000. This means that 1000MB RAM will be assigned to enfuse. This is the minimum. If your system has more, e.g. 8GB, then you should change this to 7000 (about 80%-90% of your total RAM).
Setting Bash Enfuse up in Geeqie
Geeqie is a fork of GQview, a free image viewer. This guide applies to both programs, although GQview is dead and you should use Geeqie.
Fire up Geeqie, go to Edit > Preferences > Editors, in an empty "Menu name" field enter
enfuseand in the "Command Line" field enter
%v/path/to/enfuse.sh %fe.g.
%v/home/user/enfuse.sh %fThe %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.
Setting Bash Enfuse up in digiKam
digiKam is an advanced digital photo management application. This method was tested with digiKam 0.9.4 running in KDE4, but it should work for 0.10 as well, and in KDE3.
First you need to create a .desktop file and place it in ~/.kde/share/applnk/.hidden (.kde4 if you use 0.10). Fire up a text editor and paste this into it, changing anything if necessary:
[Desktop Entry]
Comment[en_US]=
Comment=
Exec=$HOME/enfuse.sh %U
GenericName[en_US]=Bash Enfuse
GenericName=Bash Enfuse
InitialPreference=7
MimeType=image/x-pentax-pef;image/tiff;image/png;image/jpeg;image/bmp;
Name[en_US]=Bash Enfuse
Name=Bash Enfuse
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-DCOP-ServiceType=none
X-KDE-SubstituteUID=false
X-KDE-Username=
Save it as
~/.kde/share/applnk/.hidden/Bash enfuse.desktop(for digiKam 0.9) and as
~/.kde4/share/applnk/.hidden/Bash enfuse.desktop(for digiKam 0.10).
Now fire up a terminal, and run this for digiKam 0.9:
/usr/kde/3.5/bin/kbuildsycocaand/or this for digiKam 0.10:
/usr/bin/kbuildsycoca4If those commands dont exist, use a search tool like whereis or locate to find them.
The Bash Enfuse script
#!/bin/bash
#
# Bash Enfuse v0.1
#
# Copyright (C) 2008 - The Bash Enfuse authors:
# Maciek Dworak ( www.panopixel.org/bashenfuse.php )
# Frederic Mantegazza
#
# This program is distributed under the terms of the GPLv3.
#
# This script calls enfuse to fuse the input images.
# The script uses Xdialog to ask the user for parameters such as the number
# of images, output file format, output file compression, blending levels
# and whether it should blend across the -180°/+180° border for 360° panoramas.
# If the number of input images is 2 or 3, the script assumes that those
# belong in 1 group and doesn't ask for the number to save user time. If the
# number of input images is 4 then the script assumes that it should use 2
# images per group.
#
# 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 contains 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 following information is added to the enfused file name:
# "w" if the "blend across the -180°/+180° border" option was used
# the amount of levels used (note that if you selected 29 levels but your
# image was too small to support them all then the filename will still show
# 29 levels)
# if a file already exists under this name, append an index value (+1).
#
# example output file name: img001_enfuse_w_l29_3.tif
#
# '
processGroup()
{
# Creates file name and check if it exists
echo Processing "$@"
base="${1%.*}"
echo base = "$base"
output="$base"_enfuse_"$blend180filename"l"$levels"."$format"
echo output = "$output"
index2=1
# If filename does exist, append number
if [ -e "$output" ]; then
output="$base"_enfuse_"$blend180filename"l"$levels"_$index2."$format"
while [ -e "$output" ]; do
index2=$((index2 + 1))
output="$base"_enfuse_"$blend180filename"l"$levels"_$index2."$format"
done
fi
# Enfuse the images. $blend180 should not have quotation marks.
enfuse -m 1000 --compression="$compression" $blend180 -l "$levels" -o "$output" "$@"
}
process()
{
# Calculate number of groups and check if sum images are a multiple of sum images per group
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 and prsend to process
index=0
group=()
echo "creating groups"
for file in "$@"; do
group=("${group[@]}" "$(basename "$file")")
echo group = "$group"
echo longgroup = "${#group[@]}"
if (( "${#group[@]}" == nbImgPerGrp )); then
processGroup "${group[@]}"; group=();
fi;
done;
sing
}
sing()
{
startf=800
for m in `seq 1 12`; do
f=$startf
for n in `seq 1 10`; do
sudo beep -f "$f" -l 6
f=$(( $f + 50 ))
done
startf=$(( $startf + 50 ))
done
}
# Set up parameters
echo \$\@ = "$@"
imgdir=`dirname "$1"`
echo imgdir = "$imgdir"
cd "$imgdir"
# Determine number of images per group, and save user some clicking
if [ $# -eq 2 ]; then
nbImgPerGrp=2
elif [ $# -eq 3 ]; then
nbImgPerGrp=3
elif [ $# -eq 4 ]; then
nbImgPerGrp=2
else
nbImgPerGrp=`Xdialog --left --stdout --spinbox "How many images per group?" 15 60 1 015 3 ""`
fi
format=`Xdialog --left --stdout --rangebox "Choose output format\n\n1=TIFF\n2=PNG\n3=JPG" 15 60 1 3 1`
if [ $format -eq 1 ]; then
format="tif"
compression=`Xdialog --left --stdout --rangebox "Choose TIFF compression\n\n1=none\n2=packbits\n3=lzw\n4=deflate" 15 60 1 4 1`
elif [ $format -eq 2 ]; then
format="png"
else
format="jpg"
compression=`Xdialog --left --stdout --rangebox "Choose JPEG compression" 15 60 0 100 90`
fi
levels=`Xdialog --left --stdout --rangebox "Choose number of blending levels" 15 60 1 29 29`
blend180=`Xdialog --left --stdout --default-no --yesno "Blend across the 180 border? \n(for 360 panoramas)" 15 60`
if [ "$?" -eq 0 ]; then
blend180="-w"
blend180filename="w_"
fi
echo format = "$format"
echo compression = "$compression"
echo blend180 = "$blend180"
echo blend180filename = "$blend180filename"
echo levels = "$levels"
process "$@"
[ panopixel ]
[ panoramas ]
[ photography ]
[ retouching ]
[ gallery ]
[ pricelist ]
[ contact ]