]> git.wh0rd.org - home.git/blobdiff - .bin/imgcrush
crostini-vapier-setup: install edge
[home.git] / .bin / imgcrush
index 3f04460294bf50b291f323202c72e5971e505ea2..854ad4d133983afecbcd0150bb0120f8269edd21 100755 (executable)
@@ -8,19 +8,22 @@ EOF
 }
 
 crush_jpg() {
-       jpegoptim "$1"
+       local img="$1"
+       jpegoptim "${img}"
 }
 
 crush_png() {
+       local img="$1"
        # apngopt likes to corrupt images.
-       pngcrush -e .png.new "$1"
-       mv "${png}.new" "${png}"
+       pngcrush -e .png.new "${img}"
+       mv "${img}.new" "${img}"
 }
 
 crush() {
        case $1 in
        *.jpg|*.jpeg) crush_jpg "$1" ;;
        *.png)        crush_png "$1" ;;
+       *) echo "${0##*/}: unsupported format: $1" >&2 ;;
        esac
 }
 
@@ -30,8 +33,9 @@ main() {
        while [[ $# -ne 0 ]] ; do
                case $1 in
                -h) usage ;;
+               -x) set -x; shift ;;
                -*) usage 1 ;;
-               *)  crush "$1" ;;
+               *)  crush "$1"; shift ;;
                esac
        done
 }