#!/bin/bash #$1 and $2 are folders for the background foto. $3 is folder for twirling photo. #file numbers to start with COUNT=1 COUNT1=1 COUNT2=1 COUNT3=200 # angle to start with ANGLE=0 # start X position of picture (half of original image width + 20) XVALUE=200 XVALUE2=200 # saves original xvalue for use in x position calculation GVALUE=$XVALUE # total number of original files are calculated by looking into the directories and picking the one with the most images N1=`ls $1 | wc -l` N2=`ls $2 | wc -l` N3=`ls $3 | wc -l` highest_number=0 for x in $N1 $N2 $N3 do if [ $x -gt $highest_number ] then highest_number=$x fi done #Speed up animation by only taking half the total number of files of the folder with the most files) OTOTAL=$(echo "$highest_number / 4" | bc) # loop to call up the files to process. calls up files numbered from 000-999 in accending order, looping all # directories but the one with the most files while [ $COUNT -le $OTOTAL ]; do VAR=`printf "%03d" $COUNT` if [ $COUNT1 -le $N1 ]; then VAR1=$(printf "%03d" $COUNT1) else VAR1=$(printf "%03d" 1) COUNT1=1 fi echo " $1 = $VAR1 " if [ $COUNT2 -le $N2 ]; then VAR2=$(printf "%03d" $COUNT2) else VAR2=$(printf "%03d" 1) COUNT2=1 fi echo " $2 = $VAR2 " if [ $COUNT3 -le $N3 ]; then VAR3=$(printf "%03d" $COUNT3) else VAR3=$(printf "%03d" 1) COUNT3=1 fi echo " $3 = $VAR3 " #resize images from directory 1 and 2 and composites them using differences. Composites a twirling directory 3 atop which #moves for one side of the screen to the other convert \( \( $1/$VAR1.png -resize 720x576\! \) \( $2/$VAR2.png -resize 720x576\! \) -compose difference -composite \ \) \( $3/$VAR3.png -resize 360x288\! -repage -180-144 -affine `affine_rotate $XVALUE` -transform -compose copy \ +compose -crop 1920x1080$XVALUE2-288\! -flatten \) -compose src-over -composite $VAR.png #add to angle so that picture rotates 360 degrees during animation ANGLE=$(echo "scale=2; $ANGLE + 360 / $OTOTAL" | bc) #add to x position so that the picture moves across the background during animation #Distance to travel is total width of background plus foreground image (so it can't be seen at start and finish) XVALUE=$(echo "scale=2; $XVALUE - (2 * $GVALUE + 720) / $OTOTAL" | bc) # Adds +/- symbol to xvalue XVALUE2=`printf "%+f" $XVALUE` #Here the speed at which the individual sequences are run through can be set. let COUNT=COUNT+1 let COUNT1=COUNT1+1 let COUNT2=COUNT2+1 let COUNT3=COUNT3+2 done