2015-02-14 18:18:26 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# compress-pngs.sh
|
|
|
|
# Run various compression and optimization utilities on one or more PNGs
|
|
|
|
#
|
|
|
|
# Wireshark - Network traffic analyzer
|
|
|
|
# By Gerald Combs <gerald@wireshark.org>
|
|
|
|
# Copyright 2013 Gerald Combs
|
|
|
|
#
|
2018-03-08 10:18:49 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2015-02-14 18:18:26 +00:00
|
|
|
#
|
|
|
|
|
2020-01-04 23:12:06 +00:00
|
|
|
while getopts h OPTCHAR
|
|
|
|
do
|
|
|
|
case $OPTCHAR in
|
|
|
|
h|?)
|
|
|
|
echo "Usage: compress-pngs.sh file1.png [file2.png] ..." 1>&1
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2015-02-14 18:18:26 +00:00
|
|
|
|
2016-06-29 20:28:57 +00:00
|
|
|
# Other utilities:
|
|
|
|
# PNGOUT (http://advsys.net/ken/utils.htm). Closed source.
|
|
|
|
# pngquant (https://pngquant.org/). Lossy.
|
|
|
|
|
|
|
|
JOBS=8
|
2020-01-04 23:12:06 +00:00
|
|
|
PNG_FILES=$(printf "%q " "$@")
|
|
|
|
export PNG_FILES
|
2016-06-29 20:28:57 +00:00
|
|
|
(
|
|
|
|
cat <<"FIN"
|
|
|
|
|
|
|
|
all: $(PNG_FILES)
|
|
|
|
|
|
|
|
$(PNG_FILES): FORCE
|
|
|
|
@echo Compressing $@
|
2020-01-04 23:12:06 +00:00
|
|
|
@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 "$@"
|
2016-06-29 20:28:57 +00:00
|
|
|
@hash pngcrush 2>/dev/null && pngcrush -q -ow -brute -reduce -noforce "$@" pngout.$$$$.png
|
|
|
|
|
|
|
|
FORCE:
|
|
|
|
FIN
|
|
|
|
|
|
|
|
) | make -j $JOBS -f -
|