png-pre-compress: use best of singleCrunch or zopflipng

This commit is contained in:
Hans-Christoph Steiner 2020-01-02 22:04:12 +01:00
parent ab81295639
commit e2d7199f3f
No known key found for this signature in database
GPG Key ID: 3E177817BA1B9BFA
1 changed files with 24 additions and 6 deletions

View File

@ -1,15 +1,33 @@
#!/usr/bin/env sh
#!/bin/sh
set -e
set -x
for f in `find $(dirname $0)/../app/src/ -type f -name \*.png`; do
printf "\n\n=====================================================================\n"
echo $f | grep -Eo '\.9\.png$' && continue # do not optimized 9-patch, it breaks them
tmpfile=$(mktemp)
aapt singleCrunch -v -i $f -o $tmpfile
exiftool -all= $tmpfile
zopflipng--iterations=50 --keepchunks=iCCP --lossy_transparent --splitting=3 -my $tmpfile $tmpfile
mv $tmpfile $f
singlefile=$(mktemp)
zopflifile=$(mktemp)
aapt singleCrunch -v -i $f -o $singlefile || true
zopflipng --iterations=50 --keepchunks=iCCP --lossy_transparent --splitting=3 -my $f $zopflifile || true
if [ -s $singlefile ] && [ -s $zopflifile ]; then
ls -l $singlefile $zopflifile
if [ $(stat --format="%s" $singlefile) -lt $(stat --format="%s" $zopflifile) ]; then
echo "Using aapt singleCrunch for $f"
mv $singlefile $f
else
echo "Using zopflipng for $f"
mv $zopflifile $f
fi
elif [ -s $singlefile ] && [ ! -s $zopflifile ]; then
mv $singlefile $f
elif [ ! -s $singlefile ] && [ -s $zopflifile ]; then
mv $zopflifile $f
else
continue
fi
exiftool -all= $f
rm -f $singlefile $zopflifile
done
for f in metadata/*/images/*Screenshots/*.png; do