12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #!/bin/bash
- fail_old_bash() {
- echo "Sorry your bash version is too old!"
- echo "You need at least version 3.0 of bash."
- echo "Please install a newer version:"
- echo " * Either use your distro's packages."
- echo " * Or see http://www.gnu.org/software/bash/"
- exit 2
- }
- if [[ "${BASH_VERSINFO[0]}" -lt 3 ]]; then
- fail_old_bash
- fi
- if [[ -z "$1" ]] || [[ "$1" == "--help" ]]; then
- echo "Usage: $(basename $0) files..."
- exit 1
- fi
- if ! type optipng > /dev/null 2>&1; then
- echo "Can't find optipng!"
- echo "This script depends on the optipng tool to be in PATH."
- echo "Please install it or, if it is already installed add the"
- echo "directory it is in to PATH and try again."
- echo "Homepage of this tool is: http://optipng.sourceforge.net/"
- exit 1
- fi
- if ! type advpng > /dev/null 2>&1; then
- echo "Can't find advpng!"
- echo "This script depends on the advpng tool to be in PATH."
- echo "Please install it or, if it is already installed add the"
- echo "directory it is in to PATH and try again."
- echo "Homepage of this tool is: http://advancemame.sourceforge.net/comp-readme.html"
- echo "Hint: For package name in your distro, try looking for \"advancecomp\"."
- exit 1
- fi
- echo -e "Please wait, this can take a \e[1mlong\e[0m time."
- dooptipng() {
- optipng -i 0 -o 7 "$@" | \
- awk '
- /^\*\* Processing:/ { print "\nFile: " $3 }
- /^Input file size/ { print "Input: " $5,$6 }
- /^Output file size/ { print "Output: " $5,$6,$7,$8,$9,$10,$11 }
- /is already optimized/ { print "Output: No change" }
- '
- }
- doadvpng() {
- echo " In Out % Filename"
- advpng -z -4 "$@"
- }
- echo -e "\n\n\n\e[1mPass 1: optipng\e[0m\n\n\n"
- dooptipng "$@"
- echo -e "\n\n\n\e[1mPass 2: advpng\e[0m\n\n\n"
- doadvpng "$@"
- echo -e "\n\n\n\e[1mPass 3: optipng again (as advpng often makes optipng more effective)\e[0m\n\n\n"
- dooptipng "$@"
|