aboutsummaryrefslogtreecommitdiffstats
path: root/.config/init/funcs/gifo
blob: b54fa83a065987e99313ff6b0630c970a933ba57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env zsh
# optimise gifs with gifsicle

local before
local after
local ofile

for i in $@; do
	if [[ -f "$i" ]]; then
		ofile="$i.out"
		while [[ -f "$ofile" ]]; do
			ofile="$ofile.out"
		done
		du -h "$i" | cut -f 1 | read before
		echo "$i..."
		gifsicle --batch --no-ignore-errors --no-extensions -w -O3 -i "$i" \
		&& du -h "$i" | cut -f 1 | read after \
		&& echo "   $before -> $after" || echo "  failed"
	fi
done