]> git.saurik.com Git - cydia.git/blame_incremental - pngcrush.sh
The new version of Cydia needs newer translations.
[cydia.git] / pngcrush.sh
... / ...
CommitLineData
1#!/bin/bash
2
3png=$1
4out=$2
5
6steps=()
7
8src=${out}.src.png
9dst=${out}.dst.png
10
11copy=("${src}" "${dst}")
12
13function step() {
14 "$@"
15 mv -f "${dst}" "${src}"
16 steps+=($(stat -f "%z" "${src}"))
17}
18
19pngcrush=$(xcode-select --print-path)/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush
20
21if grep CgBI "${png}" &>/dev/null; then
22 if [[ ${png} != ${out} ]]; then
23 cp -a "${png}" "${out}"
24 fi
25
26 exit 0
27fi
28
29step cp -fa "${png}" "${dst}"
30
31#step "${pngcrush}" -q -rem alla -reduce -brute -iphone "${copy[@]}"
32
33#step "${pngcrush}" -q -rem alla -reduce -brute "${copy[@]}"
34#step pincrush "${copy[@]}"
35
36step "${pngcrush}" -q -rem alla -reduce -iphone "${copy[@]}"
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
42mv -f "${src}" "${out}"
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]))"