aboutsummaryrefslogtreecommitdiffstats
path: root/.config/init/funcs/gifo
diff options
context:
space:
mode:
Diffstat (limited to '.config/init/funcs/gifo')
-rwxr-xr-x.config/init/funcs/gifo21
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