]> git.saurik.com Git - cydia.git/blame - pngcrush.sh
Packages with corrupt Info.plist throw exceptions.
[cydia.git] / pngcrush.sh
CommitLineData
7fc02989
JF
1#!/bin/bash
2
3png=$1
df270703
JF
4out=$2
5
7fc02989
JF
6steps=()
7
d7c5a79d
JF
8src=${out}.src.png
9dst=${out}.dst.png
5c624298
JF
10
11copy=("${src}" "${dst}")
12
7fc02989
JF
13function step() {
14 "$@"
5c624298
JF
15 mv -f "${dst}" "${src}"
16 steps+=($(stat -f "%z" "${src}"))
7fc02989
JF
17}
18
164e8139 19pngcrush=$(xcode-select --print-path)/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush
7fc02989 20
df270703
JF
21if grep CgBI "${png}" &>/dev/null; then
22 if [[ ${png} != ${out} ]]; then
23 cp -a "${png}" "${out}"
24 fi
25
26 exit 0
27fi
7fc02989 28
5c624298 29step cp -fa "${png}" "${dst}"
7fc02989 30
5c624298 31#step "${pngcrush}" -q -rem alla -reduce -brute -iphone "${copy[@]}"
7fc02989 32
5c624298
JF
33#step "${pngcrush}" -q -rem alla -reduce -brute "${copy[@]}"
34#step pincrush "${copy[@]}"
7fc02989 35
5c624298 36step "${pngcrush}" -q -rem alla -reduce -iphone "${copy[@]}"
7fc02989
JF
37
38#"${pngcrush}" -q -rem alla -reduce -brute -iphone "${png}" 1.png
39#"${pngcrush}" -q -iphone _.png 2.png
40#ls -la 1.png 2.png
41
5c624298 42mv -f "${src}" "${out}"
7fc02989
JF
43
44echo -n "${png##*/} "
45for ((i = 0; i != ${#steps[@]}; ++i)); do
46 if [[ $i != 0 ]]; then
47 echo -n " "
48 fi
49
50 echo -n "${steps[i]}"
51done
52
53printf $' %.0f%%\n' "$((steps[${#steps[@]}-1] * 100 / steps[0]))"