From 7fa03a9c82c7e1e23fb0b3f8097ddb6dff0666d3 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 19 Aug 2017 14:56:12 -0400 Subject: [PATCH] imgcrush: wrapper around diff crush tools --- .bin/imgcrush | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 .bin/imgcrush 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 "$@" -- 2.39.5