OLD | NEW |
---|---|
(Empty) | |
1 #!/bin/bash | |
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 ALL_DIRS=" | |
7 ash/resources | |
8 ui/resources | |
9 chrome/app/theme | |
10 chrome/browser/resources | |
11 chrome/renderer/resources | |
12 webkit/glue/resources | |
13 remoting/resources | |
14 remoting/webapp | |
15 " | |
16 | |
17 function sanitize_file { | |
18 tput el | |
19 echo -ne "$1\r" | |
20 local file=$1 | |
21 local name=$(basename $file) | |
22 pngcrush -d $TMP_DIR -brute -reduce -rem text -rem mkBT \ | |
23 -rem mkTS $file > /dev/null | |
Nico
2013/01/10 23:47:37
I asked leiz/msw about the best way to crunch PNG
oshima
2013/01/11 00:12:11
I took the command from chrome/app/theme/README bu
| |
24 mv "$TMP_DIR/$name" "$file" | |
25 } | |
26 | |
27 function sanitize_dir { | |
28 local dir=$1 | |
29 for f in $(find $dir -name "*.png"); do | |
30 sanitize_file $f | |
31 done | |
32 } | |
33 | |
34 if [ ! -e ../.gclient ]; then | |
35 echo "$0 must be run in src directory" | |
36 exit 1 | |
37 fi | |
38 | |
39 # Make sure we have pngcrush installed. | |
40 dpkg -s pngcrush > /dev/null 2>&1 | |
41 if [ "$?" != "0" ]; then | |
42 read -p "Couldn't fnd pngcrush. Do you want to install? (y/n)" | |
43 [ "$REPLY" == "y" ] && sudo apt-get install pngcrush | |
44 [ "$REPLY" == "y" ] || exit | |
45 fi | |
46 | |
47 # Create tmp directory for crushed png file. | |
48 TMP_DIR=$(mktemp -d) | |
49 | |
50 # Make sure we cleanup temp dir | |
51 trap "rm -rf $TMP_DIR" EXIT | |
52 | |
53 # If no arguments passed, sanitize all directories. | |
54 DIRS=$* | |
55 set ${DIRS:=$ALL_DIRS} | |
56 | |
57 for d in $DIRS; do | |
58 echo "Sanitizing png files in $d" | |
59 sanitize_dir $d | |
60 echo | |
61 done | |
62 | |
OLD | NEW |