forked from holman/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmustacheme
executable file
·56 lines (50 loc) · 1.38 KB
/
mustacheme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
#
# mustacheme
# expanded from an idea from Rick Olson (@technoweenie)
#
# Takes a .gif, splits it into constituent frames, mustaches each, restitches
# the gif, and uploads to cloudapp.
#
# This leverages the nifty service mustachify.me, which will analyze your photo,
# identify faces, and add a mustache to your image.
#
# If the .gif is a remote file, we'll download it and blow it up locally.
#
# $1 - the path of the gif
#
# Examples:
#
# mustacheme holman-jumping-off-cliff-into-butter.gif
# mustacheme http://github.com/holman/butter/blob/master/holman-butter.gif
#
# Dependencies:
#
# - ImageMagick. If you're on a Mac, run:
# brew install imagemagick
# - wget
# - cloudapp: https://github.com/holman/dotfiles/blob/master/bin/cloudapp
# - gifme: https://github.com/holman/gifme
set -e
# Set up mustacheme temporary working directory
output=/tmp/mustacheme
rm -rf $output
mkdir $output
if [[ $1 == http* ]]
then
wget $1 -O /tmp/mustache-download.gif
file=/tmp/mustache-download.gif
else
file="$1"
fi
# Blow apart the GIF
convert $1 -coalesce $output/frame_%03d.gif
# Mustache each frame
for frame in $output/*.gif
do
url=$(cloudapp $frame | grep Uploaded | awk '{print substr($0, index($0, "http://"))}')
url="$url/$(basename $frame)"
wget "http://mustachify.me/?src=$url" -O "$frame-stache"
done
# Ding! Fries are done.
gifme $output/*-stache -d 0