aboutsummaryrefslogtreecommitdiffstats
path: root/.config/init/funcs/gifo
blob: 854b45ac173911d228ffd6c8dc989a0f2c0c40d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/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 --no-ignore-errors -w -O3 "$i" -o "$i.out"
		[[ -f "$ofile" ]] && rm "$i" && mv "$ofile" "$i" && \
		du -h "$i" | cut -f 1 | read after && \
		echo "   $before -> $after" || echo "  failed"
	fi
done