diff options
author | Evan McClain <aeroevan@gmail.com> | 2011-10-28 04:34:29 -0400 |
---|---|---|
committer | Evan McClain <aeroevan@gmail.com> | 2011-10-29 15:17:52 -0400 |
commit | f199486460cfd3aeba16f504c9e33945ef789c56 (patch) | |
tree | ba1a889e842f196ac9c0766d3a1953dabe8ffa44 | |
parent | c8b90beb245ad700c1d7b8f00b75215a83be4193 (diff) | |
download | vendor_replicant-f199486460cfd3aeba16f504c9e33945ef789c56.zip vendor_replicant-f199486460cfd3aeba16f504c9e33945ef789c56.tar.gz vendor_replicant-f199486460cfd3aeba16f504c9e33945ef789c56.tar.bz2 |
Use pngcrush -brute by default.
But fallback to optipng -o7 and then pngout.
This saves ~2M in final .zip size at a cost of ~5 min of build time on
my laptop.
Change-Id: Ic56f677bdc8250f4088f4dbfbfd555ceed5616c2
Signed-off-by: Evan McClain <aeroevan@gmail.com>
-rwxr-xr-x | tools/opticharger | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/tools/opticharger b/tools/opticharger index f8a9d8a..b4345c4 100755 --- a/tools/opticharger +++ b/tools/opticharger @@ -1,7 +1,7 @@ #!/bin/sh # # Super-mega opticharger of doom -# Shrinks apks by running pngcrush on png images +# Shrinks apks by running pngcrush or optipng or pngout on png images # # Point APKCERTS at the full path to a generated apkcerts.txt file, such as: # /home/shade/dev/sources/android-cm-eclair/out/target/product/dream_sapphire/obj/PACKAGING/target_files_intermediates/cyanogen_dream_sapphire-target_files-eng.shade/META/apkcerts.txt @@ -19,7 +19,6 @@ fi set -e QUIET=1 -QFLAG=-q BASE=`pwd` TMPDIR=/tmp/opticharge-$$ @@ -38,9 +37,29 @@ then echo "Invalid path to apkcerts.txt, set APKCERTS to the correct path." fi -if [ "`which pngcrush`" = "" ]; +if [ "$(which pngcrush)" != "" ]; then - echo "Please install pngcrush" + optimize_png () { + pngcrush -q -brute $1 ${1}.out 1> /dev/null 2> /dev/null + mv ${1}.out ${1} + } +elif [ "$(which optipng)" != "" ]; +then + optimize_png () { + optipng -o7 -quiet $1 1> /dev/null 2> /dev/null + } +elif [ "$(which pngout-static)" != "" ]; +then + optimize_png () { + pngout-static $1 + } +elif [ "$(which pngout)" != "" ]; +then + optimize_png () { + pngout $1 + } +else + echo "Please install pngcrush, optipng, or pngout" exit 1; fi @@ -97,11 +116,7 @@ then for x in `find . -name "*.png" | grep -v "\.9.png$" | tr "\n" " "` do [ $QUIET ] || echo "Crushing $x" - pngcrush $QFLAG $x $x.crushed 1>/dev/null - if [ -e "$x.crushed" ]; - then - mv $x.crushed $x - fi + optimize_png $x done cp $BASE/$1 $BASE/$1.old |