]>
Commit | Line | Data |
---|---|---|
7fc02989 JF |
1 | #!/bin/bash |
2 | ||
3 | png=$1 | |
df270703 JF |
4 | out=$2 |
5 | ||
7fc02989 JF |
6 | steps=() |
7 | ||
d7c5a79d JF |
8 | src=${out}.src.png |
9 | dst=${out}.dst.png | |
5c624298 JF |
10 | |
11 | copy=("${src}" "${dst}") | |
12 | ||
7fc02989 JF |
13 | function step() { |
14 | "$@" | |
5c624298 JF |
15 | mv -f "${dst}" "${src}" |
16 | steps+=($(stat -f "%z" "${src}")) | |
7fc02989 JF |
17 | } |
18 | ||
164e8139 | 19 | pngcrush=$(xcode-select --print-path)/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush |
7fc02989 | 20 | |
df270703 JF |
21 | if grep CgBI "${png}" &>/dev/null; then |
22 | if [[ ${png} != ${out} ]]; then | |
23 | cp -a "${png}" "${out}" | |
24 | fi | |
25 | ||
26 | exit 0 | |
27 | fi | |
7fc02989 | 28 | |
5c624298 | 29 | step 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 | 36 | step "${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 | 42 | mv -f "${src}" "${out}" |
7fc02989 JF |
43 | |
44 | echo -n "${png##*/} " | |
45 | for ((i = 0; i != ${#steps[@]}; ++i)); do | |
46 | if [[ $i != 0 ]]; then | |
47 | echo -n " " | |
48 | fi | |
49 | ||
50 | echo -n "${steps[i]}" | |
51 | done | |
52 | ||
53 | printf $' %.0f%%\n' "$((steps[${#steps[@]}-1] * 100 / steps[0]))" |