#!/bin/bash #file numbers to start with #Two variable must be given: background and foreground image folders. #total number of original files are calculated by looking into the directories and picking the one with the most images COUNT1=1 COUNT2=1 N1=`ls $1 | wc -l` N2=`ls $2 | wc -l` highest_number=0 for x in $N1 $N2 do if [ $x -gt $highest_number ] then highest_number=$x fi done OTOTAL=$( echo "$highest_number / 4 " | bc ) # variables for degree of swirl and implosion as well as the name of the output file for i in $(seq 1 $OTOTAL); do S_ARG=$(echo "$i * 15" | bc) I_ARG=$(echo "scale=3; $i / 60" | bc) VAR3=$(printf "%03d" $i) # For the folder with less files in it. # Reverts the number of the current file being called up to 001 when all files in the folder have been called. if [ $COUNT1 -le $N1 ]; then VAR1=$(printf "%03d" $COUNT1) else VAR1=$(printf "%03d" $COUNT1) COUNT1=1 fi if [ $COUNT2 -le $N2 ]; then VAR2=$(printf "%03d" $COUNT2) else VAR2=$(printf "%03d" $COUNT2) COUNT2=1 fi # Swirls and implodes a sequence of images. Composes it over a background sequence. 720x576 image sizes assumed # shave and border necessary because otherwise there are vestiges of the whirlpool image at the sides. convert $1/$VAR1.png \( $2/$VAR2.png -bordercolor none -border 150x150 -swirl $S_ARG -implode $I_ARG -shave 150x150 \) -compose src-over -composite $VAR3.png echo " $VAR3 " let COUNT1=COUNT1+4 let COUNT2=COUNT2+4 # Break once all files in the larger folder are called if [ $VAR3 -eq $OTOTAL ]; then break fi done