blob: 0598451e6231288f88fb4492a7b86d0c102ec7ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#!/bin/bash
png=$1
out=$2
steps=()
src=${out}.src.png
dst=${out}.dst.png
copy=("${src}" "${dst}")
function step() {
"$@"
mv -f "${dst}" "${src}"
steps+=($(stat -f "%z" "${src}"))
}
pngcrush=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush
if grep CgBI "${png}" &>/dev/null; then
if [[ ${png} != ${out} ]]; then
cp -a "${png}" "${out}"
fi
exit 0
fi
step cp -fa "${png}" "${dst}"
#step "${pngcrush}" -q -rem alla -reduce -brute -iphone "${copy[@]}"
#step "${pngcrush}" -q -rem alla -reduce -brute "${copy[@]}"
#step pincrush "${copy[@]}"
step "${pngcrush}" -q -rem alla -reduce -iphone "${copy[@]}"
#"${pngcrush}" -q -rem alla -reduce -brute -iphone "${png}" 1.png
#"${pngcrush}" -q -iphone _.png 2.png
#ls -la 1.png 2.png
mv -f "${src}" "${out}"
echo -n "${png##*/} "
for ((i = 0; i != ${#steps[@]}; ++i)); do
if [[ $i != 0 ]]; then
echo -n " "
fi
echo -n "${steps[i]}"
done
printf $' %.0f%%\n' "$((steps[${#steps[@]}-1] * 100 / steps[0]))"
|