Reputation: 11363
I'm generating panoramas using the command line versions of the Hugin toolset. At the execution of the script, all images are sorted into folders of n images that consist of a single panorama. Depending on the execution of the blend process, one of two filenames can result: pano.tif
and pano_blended_fused.tif
.
No matter which file is generated, I want to convert that one to a jpg and resize. My current code is
dirlist=$(find . -mindepth 1 -maxdepth 1 -type d \( ! -name completed \) | sort -n)
for dir in $dirlist
do
#pano generating gode goes here
#Downsize and convert panorama
#######################################################################
tifImage=
jpgImage=
if [ -e "pano.tif" ]; then
tifImage="pano.tif"
jpgImage="pano.jpg"
echo "Working on pano.tif"
echo ""
elif [ -e "pano_blended_fused" ]; then
tifImage="pano_blended_fused.tif"
jpgImage="pano_blended_fused.jpg"
echo "Working on pano_blended_fused.tif"
echo ""
fi
#convert pano to jpg and get count of images in photo folder
echo ""
echo "Converting $image to jpg and creating two versions"
echo ""
mogrify -format jpg $tifImage >> "$imagePath/$dir/log.txt"
num=$(ls -l "$webPath/photos" | wc -l)
prefix=$((num+1))
#convert full size pano to 1000 pixels high and rename with prefix number
#move to /photos folder
convert $jpgImage -geometry x1000 "$prefix-pano.jpg" >> "$imagePath/$dir/log.txt"
mv "$prefix-pano.jpg" "$webPath/photos" >> "$imagePath/$dir/log.txt"
#convert full size pano to 600 pixels wide and rename with prefix number
#move to /thumbs folder
convert $jpgImage -geometry 600x "$prefix-pano.jpg" >> "$imagePath/$dir/log.txt"
mv "$prefix-pano.jpg" "$webPath/thumbs" >> "$imagePath/$dir/log.txt"
done
I just did a batch of pictures last night, and of the 15 panoramas to be generated, only 9 made it to the destiniation folder. All others threw an error at the first convert
command stating that it was missing an image filename n-pano.tif
, when the $tifImage
varuiable should have been pano_blended_fused.tif
What do I need to do so that the pano_blended_fused
images can go through the conversion process?
Upvotes: 1
Views: 233
Reputation: 1433
You forgot to include the complete filename, the extension is missing:
elif [ -e "pano_blended_fused" ]; then
vs.
elif [ -e "pano_blended_fused.tif" ]; then
Therefore the variables were never changed and convert
didn't get what it wanted.
Upvotes: 2