aboutsummaryrefslogtreecommitdiffstats
path: root/.config/init/funcs/gifo
blob: 1ce61c332dc4e8dec781db263eaea1f876db095c (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 -w -O3 -i "$i" \
		&& du -h "$i" | cut -f 1 | read after \
		&& echo "   $before -> $after" || echo "  failed"
	fi
done