diff options
author | katherine <shmibs@shmibbles.me> | 2017-03-01 00:54:06 -0700 |
---|---|---|
committer | katherine <shmibs@shmibbles.me> | 2017-03-01 00:54:06 -0700 |
commit | 5aba9de367932be46aa471c71076d9e623d5abce (patch) | |
tree | f4284a126603af874de9731b357041df1f2fd1d0 /.config/init/funcs/gifo | |
parent | ce4b99960f11ee9371ea4468247643d42ac05f9b (diff) | |
download | dotfiles-5aba9de367932be46aa471c71076d9e623d5abce.tar.gz |
snapshot
various smöl changes
Diffstat (limited to '.config/init/funcs/gifo')
-rwxr-xr-x | .config/init/funcs/gifo | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/.config/init/funcs/gifo b/.config/init/funcs/gifo new file mode 100755 index 0000000..854b45a --- /dev/null +++ b/.config/init/funcs/gifo @@ -0,0 +1,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 |