From: Mike Frysinger Date: Sat, 19 Aug 2017 18:56:12 +0000 (-0400) Subject: imgcrush: wrapper around diff crush tools X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=7fa03a9c82c7e1e23fb0b3f8097ddb6dff0666d3;p=home.git imgcrush: wrapper around diff crush tools --- diff --git a/.bin/imgcrush b/.bin/imgcrush new file mode 100755 index 0000000..3f04460 --- /dev/null +++ b/.bin/imgcrush @@ -0,0 +1,38 @@ +#!/bin/bash + +usage() { + cat < +EOF + exit ${1:-0} +} + +crush_jpg() { + jpegoptim "$1" +} + +crush_png() { + # apngopt likes to corrupt images. + pngcrush -e .png.new "$1" + mv "${png}.new" "${png}" +} + +crush() { + case $1 in + *.jpg|*.jpeg) crush_jpg "$1" ;; + *.png) crush_png "$1" ;; + esac +} + +main() { + set -e + + while [[ $# -ne 0 ]] ; do + case $1 in + -h) usage ;; + -*) usage 1 ;; + *) crush "$1" ;; + esac + done +} +main "$@"