forked from Mineclonia/Mineclonia
Add script to optimize PNG textures using optipng
This commit is contained in:
parent
6abdbbbd13
commit
9d3cd2e7ef
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
# Optimize all PNG textures using optipng, add them to Git index.
|
||||
# Run this script from the root of the repository for the effect.
|
||||
set -eu
|
||||
LANG=C
|
||||
|
||||
PNG_FILES=$(find . -type f -name '*.png')
|
||||
|
||||
get_png_size_total() {
|
||||
cat ${PNG_FILES} \
|
||||
|wc -c
|
||||
}
|
||||
|
||||
PNG_SIZE_TOTAL_BEFORE=$(get_png_size_total)
|
||||
|
||||
for PNG_FILE in ${PNG_FILES}; do
|
||||
if git checkout "${PNG_FILE}"; then
|
||||
printf '%s\n' "${PNG_FILE}"
|
||||
optipng -o7 -zm1-9 -strip all "${PNG_FILE}"
|
||||
git add "${PNG_FILE}"
|
||||
fi
|
||||
done
|
||||
|
||||
PNG_SIZE_TOTAL_AFTER=$(get_png_size_total)
|
||||
|
||||
printf 'PNG size total before:\t%s\n' "${PNG_SIZE_TOTAL_BEFORE}"
|
||||
printf 'PNG size total after:\t%s\n' "${PNG_SIZE_TOTAL_AFTER}"
|
Loading…
Reference in New Issue