#!/bin/bash -x # # perspective output name must be .gif pfile=perspective_animation.gif ##file number to start with COUNT=1 ##checks only the size of the first file checksize=$1/001.png function imagesize { width=`identify -format %w $checksize` height=`identify -format %h $checksize` } imagesize ## total number of original files OTOTAL=`ls $1 | wc -l` ## sloppy addition so that the angle doesn't change too slowly if [ $OTOTAL -lt 180 ]; then OANG=$OTOTAL elif [ $OTOTAL -lt 360 ]; then OANG=`expr $OTOTAL / 2` elif [ $OTOTAL -lt 720 ]; then OANG=`expr $OTOTAL / 4` ## more than this number of files will take forever, so might as well break if there are more else exit 0 fi # provide the frame delay in the gif animation delay=10 # note - choose anginc and initang to keep from having a frame looking directly edge on # otherwise get a blank white picture! ##got rid of this. angle is calculated later on, so that the number of files is taken into account #anginc=10 initang=5 tmp="perspective_animate_$$.png" trap "rm -f $tmp; exit 0" 0 trap "rm -f $tmp; exit 1" 1 2 3 15 ##added this because two angle arguments are required one with and one without floating points ang1=$initang ang2=$initang xx=x ##added this so that different file names are called up while [ $COUNT -le $OTOTAL ]; do VAR=`printf "%03d" $COUNT`.png ##moved this down here so that ifile is changed during while loop. ##input directory now first argument on the commandline ifile=$1/$VAR ##got rid of this to take greater file numbers into account #while [ $ang -le 360 ] # do if [ $ang2 -gt 180 ] then newang=`expr $ang2 - 360` else newang=$ang1 fi # animate pan # 3Drotate pan=$newang zoom=-1.5 $ifile $tmp # animate tilt # 3Drotate tilt=$newang zoom=-1.5 $ifile $tmp # animate roll # 3Drotate roll=$newang zoom=-1.5 $ifile $tmp # animate pan about tilt=45 # 3Drotate pan=$newang tilt=45 zoom=-1.5 $ifile $tmp # tilt=30 animate pan # # set the fixed angle(s) and the animated angle 3Drotate tilt=$newang pan=$newang zoom=-1.5 $ifile $tmp if [ $ang2 -eq $initang ] then convert $tmp -delay $delay $pfile else convert -delay $delay $pfile -page $width$xx$height+0+0 $tmp -page $width$xx$height $pfile fi ##changed from $ang to $newang so that the angle doesn't go over 180 ang1=$(echo "scale=2; $newang + $(echo "scale=2; 360 / $OANG" | bc)" | bc) ##added this because decimals don't work in if statements ang2=$(echo $ang1 | awk '{printf "%.0f",$1}') ##added sloppily so that gif file isn't created more than once initang=195 let COUNT=COUNT+1 echo $COUNT done convert $pfile -loop 0 $pfile