Fix 2nd argument not valid due to image path

This commit is contained in:
VirtuBox 2019-07-19 10:37:30 +02:00
parent 5d9d604436
commit c80ebccbd2
No known key found for this signature in database
GPG Key ID: 22EB296C97BAD476
2 changed files with 14 additions and 28 deletions

View File

@ -2,7 +2,7 @@
![img-optimize](https://raw.githubusercontent.com/VirtuBox/img-optimize/master/img-optimize.png)
![GitHub](https://img.shields.io/github/license/VirtuBox/img-optimize.svg) ![GitHub release](https://img.shields.io/github/release/VirtuBox/img-optimize.svg) ![GitHub last commit](https://img.shields.io/github/last-commit/VirtuBox/img-optimize.svg) ![Github stars](https://img.shields.io/github/stars/VirtuBox/img-optimize.svg)
[![Travis (.org)](https://img.shields.io/travis/VirtuBox/img-optimize.svg)](https://travis-ci.org/VirtuBox/img-optimize) ![GitHub](https://img.shields.io/github/license/VirtuBox/img-optimize.svg) ![GitHub release](https://img.shields.io/github/release/VirtuBox/img-optimize.svg) ![GitHub last commit](https://img.shields.io/github/last-commit/VirtuBox/img-optimize.svg) ![Github stars](https://img.shields.io/github/stars/VirtuBox/img-optimize.svg)
## Prerequisite

View File

@ -23,20 +23,21 @@ _help() {
echo "Usage: img-optimize [options] <images path>"
echo "If images path isn't defined, img-optimize will use the current directory "
echo " Options:"
echo " --jpg <images path> ..... optimize all jpg images"
echo " --png <images path> ..... optimize all png images"
echo " --webp <images path> ..... convert all images in webp"
echo " --nowebp <images path> ..... optimize all png & jpg images"
echo " --all <images path> ..... optimize all images (png + jpg + webp)"
echo " --jpg ..... optimize all jpg images"
echo " --png ..... optimize all png images"
echo " --webp ..... convert all images in webp"
echo " --nowebp ..... optimize all png & jpg images"
echo " --all ..... optimize all images (png + jpg + webp)"
echo " -i, --interactive ..... run img-optimize in interactive mode"
echo " -q, --quiet ..... run image optimization quietly"
echo " --path <images path> ..... define images path"
echo " Other options :"
echo " -h, --help, help ... displays this help information"
echo " --cmin [+|-]<n> ... File's status was last changed n minutes ago."
echo " act find cmin argument (+n : greater than n, -n : less than n, n : exactly n)"
echo "Examples:"
echo " optimize all jpg images in /var/www/images"
echo " img-optimize --jpg /var/www/images"
echo " img-optimize --jpg --path /var/www/images"
echo ""
return 0
}
@ -54,42 +55,22 @@ else
case "$1" in
--jpg)
JPG_OPTIMIZATION="y"
if [ "$2" ]; then
IMG_PATH=$2
shift
fi
;;
--png)
PNG_OPTIMIZATION="y"
if [ "$2" ]; then
IMG_PATH=$2
shift
fi
;;
--nowebp)
JPG_OPTIMIZATION="y"
PNG_OPTIMIZATION="y"
WEBP_OPTIMIZATION="n"
if [ "$2" ]; then
IMG_PATH=$2
shift
fi
;;
--webp)
WEBP_OPTIMIZATION="y"
if [ "$2" ]; then
IMG_PATH=$2
shift
fi
;;
--all)
PNG_OPTIMIZATION="y"
JPG_OPTIMIZATION="y"
WEBP_OPTIMIZATION="y"
if [ "$2" ]; then
IMG_PATH=$2
shift
fi
;;
-i | --interactive)
INTERACTIVE_MODE="1"
@ -105,6 +86,11 @@ else
shift
fi
;;
--path)
if [ "$2" ]; then
IMG_PATH="$2"
fi
;;
-h | --help | help)
_help
exit 1