Skip to content

Instantly share code, notes, and snippets.

@hellocatfood
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellocatfood/27da81b76c5b2da975c2 to your computer and use it in GitHub Desktop.
Save hellocatfood/27da81b76c5b2da975c2 to your computer and use it in GitHub Desktop.
Tiles a gif and then overlays it over a static image.
#!/bin/bash
#tiles a gif and then overlays it over a static image. Only tested with jpgs and pngs on Ubuntu 14.04
#usage: ./sparkle.sh sparklegif.gif /directory/of/images/ (use the full location path)
sparklegif=$1
imagedirectory=$2
#create a large tile of the looping gif. It needs to be larger than the input static image, so "-scale" the $sparklegif if necessary or change the viewport value
convert $sparklegif -coalesce -virtual-pixel tile -set option:distort:viewport 1000x1000 -distort SRT 0 sparklegif_temp.gif
for image in "$imagedirectory"*
do
#get path of file
path=$( readlink -f "$( dirname "$image" )" )
#get filename minus extension
file=$(basename "$image")
filename="${file%.*}"
#get extension
extension="${image##*.}"
convert "$image" null: sparklegif_temp.gif -layers Composite "$path"/"$filename"_sparkle.gif
done
rm sparklegif_temp.gif
#!/bin/bash
#$1 is an input gif
#$2 is folder full of jps
#usage ./sparkle_video.sh animation.gif /path/to/folder/of/jpgs
#this will overlay the specified gif onto a static image and make it into an avi video
mkdir finished
rm *.avi
for image in $2
do
#combine an image with the animated gif
convert "$image" null: $1 -layers Composite output.jpg
for file in output*.jpg
do
#number of times to duplicate the file (between 1 and 6)
number=1
while [ $number -le 4 ]
do
#get path of file
path=$( readlink -f "$( dirname "$file" )" )
#get filename minus extension
file=$(basename "$file")
filename="${file%.*}"
#get extension
extension="${file##*.}"
#copy the file to a new file
cp $file "$path"/"$filename"_"$number".$extension
number=`expr $number + 1`
done
done
a=1
for i in *.jpg; do
new=$(printf "abcd_%04d.jpg" ${a}) #04 pad to length of 4
mv ${i} ${new}
let a=a+1
done
avconv -i abcd_%04d.jpg -y 8x_temp.avi
mv *.avi finished/
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment