-
Notifications
You must be signed in to change notification settings - Fork 1
/
party.sh
executable file
·54 lines (41 loc) · 1.19 KB
/
party.sh
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
#!/usr/bin/env bash
# Generate a `:something-intensifies:` Slack emoji, given a reasonable input
# input. I recommend grabbing an emoji from https://emojipedia.org/
set -euo pipefail
if [ $# -eq 0 ]; then
echo "Usage: $0 input.png"
exit 1
fi
input="$1"
cd "$(dirname "$input")"
filename=$(basename -- "$input")
tempdir="$(uuidgen)"
# Add 10% padding to width and height, then scale to 128x128
width=$(identify -format "%w" "$filename")
height=$(identify -format "%h" "$filename")
new_width=$(( width + width / 10 ))
new_height=$(( height + height / 10 ))
extended="${filename%.*}-extended.png"
convert \
-gravity center \
-background none \
-extent ${new_width}x${new_height} \
-geometry 128x128 \
"$filename" \
"$extended"
mkdir "$tempdir"
for ((i=1;i<=200;i=$i+12)); do
convert "$input" -modulate 100,100,$i "$tempdir/$(printf "%05d" $i).gif"
done
# Some combination of `-coalesce -fuzz -dither -layers Optimize +map` helps to reduce overall filesize
convert -delay 4 -loop 0 \
-coalesce \
-fuzz 2% \
+dither \
-layers Optimize \
+map \
$tempdir/*.gif "${input%.*}-party.gif"
# Clean up
rm -rf "$tempdir"
# We did it y'all
echo "Created ${input%.*}-party.gif. Enjoy!"