Created
September 29, 2015 05:29
-
-
Save cincodenada/6716e4977040548c638f to your computer and use it in GitHub Desktop.
Script that takes a gif and attempts to make a crossview 3D gif by duplicating sbs and delaying the right half by two frames.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FRAME="frame.gif" | |
INFILE=$1 | |
OUTFILE=$2 | |
MOVEBY=2 | |
NUMFRAMES=`gifsicle -I $INFILE | | |
perl -ne 'if(/(\d+) images/) { print $1;}'` | |
echo "Cleaning up any previous runs..." | |
rm -rf left | |
rm -rf right | |
rm -rf sbs | |
mkdir left | |
echo "Extracting $NUMFRAMES frames..." | |
gifsicle -e $INFILE -o left/$FRAME | |
cp -r left right | |
for i in `seq -w $(($NUMFRAMES-1)) -1 0` | |
do | |
echo "mv right/${FRAME}.$i right/${FRAME}.`echo \"$i+$MOVEBY\" | bc`" | |
mv right/${FRAME}.$i right/${FRAME}.`echo "$i+$MOVEBY" | bc` | |
done | |
for i in `seq 0 $((MOVEBY-1))` | |
do | |
mv right/${FRAME}.`echo "$NUMFRAMES+$i" | bc` right/${FRAME}.$i | |
done | |
for i in `seq -w 0 $(($NUMFRAMES-1))` | |
do | |
mv right/${FRAME}.`echo $i | bc` right/${FRAME}.$i | |
done | |
mkdir sbs | |
for i in `seq -w 0 $(($NUMFRAMES-1))` | |
do | |
convert left/${FRAME}.$i right/${FRAME}.$i +append sbs/${FRAME}.$i | |
done | |
gifsicle --loop=0 sbs/* > $OUTFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment