Add the script to losslessly optimize data

This should be run before making a release, and after adding new data.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12804 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
curaga 2013-05-30 10:21:59 +00:00
parent 1c48d76343
commit adf370519f

49
data/optimize_data.sh Executable file
View File

@ -0,0 +1,49 @@
#!/bin/sh
#
# (C) 2013 Lauri Kasanen, under the GPLv3
#
# Script to optimize the data, currently PNG, JPEG, B3DZ.
# Run it before making a release, and after adding new data.
# Takes 5-10min depending on your cpu.
# Spaces in filenames are supported.
# Start checks
fail=0
which awk >/dev/null && which jpegtran >/dev/null && which advdef >/dev/null && \
which advzip >/dev/null || fail=1
[ "$fail" -eq 1 ] && echo "Please install awk, advdef and jpegtran" && exit 1
# Defines
IFS="
"
export LANG=C
# Go
BEFORE=`du -sk | awk '{print $1}'`
for png in `find -name "*.png"`; do
advdef -z4 "$png"
done
for jpeg in `find -name "*.jpg"`; do
jpegtran -optimize -copy none -outfile "$jpeg".$$ "$jpeg"
mv "$jpeg".$$ "$jpeg"
done
for b3dz in `find -name "*.b3dz"`; do
advzip -z4 "$b3dz"
done
# Add optimizations for other types if necessary
AFTER=`du -sk | awk '{print $1}'`
# Print stats out
echo $BEFORE $AFTER | awk '{print "Before: " $1/1024 "mb, after: " $2/1024 "mb" }'
echo $BEFORE $AFTER | awk '{print "Saved " (1-($2/$1)) * 100 "%" }'