diff options
author | Gerald Combs <gerald@wireshark.org> | 2020-01-04 15:12:06 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2020-01-05 01:52:01 +0000 |
commit | 68a21c46f6b9e6e2a9c17e201fc5c130a8a6f492 (patch) | |
tree | b58eec2de3dfff8d2f04bc28e00fbbd8768d2ab4 /tools | |
parent | 9ca39e1c56a87fdcf3ca037972cf864119a6d601 (diff) |
tools: Make compress-pngs a standard utility.
Switch from using `find` to find PNGs to simply accepting a list of
files as arguments.
Pass long arguments to some compressors.
Change-Id: I37884049026fea714d0dd30b08496744c6272379
Reviewed-on: https://code.wireshark.org/review/35646
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/compress-pngs.sh | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/tools/compress-pngs.sh b/tools/compress-pngs.sh index 50886da44e..339629bac2 100755 --- a/tools/compress-pngs.sh +++ b/tools/compress-pngs.sh @@ -10,35 +10,34 @@ # SPDX-License-Identifier: GPL-2.0-or-later # -FILE_LIST_CMD="find . -type f -name \"*.png\"" - -if [ -n "$1" ] ; then - FILE_LIST_CMD="echo $1" -fi +while getopts h OPTCHAR +do + case $OPTCHAR in + h|?) + echo "Usage: compress-pngs.sh file1.png [file2.png] ..." 1>&1 + exit 0 + ;; + esac +done # Other utilities: # PNGOUT (http://advsys.net/ken/utils.htm). Closed source. # pngquant (https://pngquant.org/). Lossy. JOBS=8 -export FILE_LIST_CMD +PNG_FILES=$(printf "%q " "$@") +export PNG_FILES ( - echo -n "PNG_FILES =" - bash -c "$FILE_LIST_CMD" | while read -r PNG_FILE ; do - echo -e " \\" - echo -e -n "\\t${PNG_FILE}" - - done cat <<"FIN" all: $(PNG_FILES) $(PNG_FILES): FORCE @echo Compressing $@ - @hash oxipng 2>/dev/null && oxipng -o 4 --strip safe "$@" - @hash optipng 2>/dev/null && optipng -o3 -quiet "$@" - @hash advpng 2>/dev/null && advpng -z -4 "$@" - @hash advdef 2>/dev/null && advdef -z -4 "$@" + @hash oxipng 2>/dev/null && oxipng --opt 4 --strip safe "$@" + @hash optipng 2>/dev/null && optipng -o3 -quiet "$@" + @hash advpng 2>/dev/null && advpng --recompress --shrink-insane "$@" + @hash advdef 2>/dev/null && advdef --recompress --shrink-insane "$@" @hash pngcrush 2>/dev/null && pngcrush -q -ow -brute -reduce -noforce "$@" pngout.$$$$.png FORCE: |