Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4015)

Unified Diff: build/sanitize-png-files.sh

Issue 11825019: a utility script to pngcrush png files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix trap Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/sanitize-png-files.sh
diff --git a/build/sanitize-png-files.sh b/build/sanitize-png-files.sh
new file mode 100755
index 0000000000000000000000000000000000000000..62faf6bd6a080273ba3679a582853376d64ea3a2
--- /dev/null
+++ b/build/sanitize-png-files.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+ALL_DIRS="
+ash/resources
+ui/resources
+chrome/app/theme
+chrome/browser/resources
+chrome/renderer/resources
+webkit/glue/resources
+remoting/resources
+remoting/webapp
+"
+
+function sanitize_file {
+ tput el
+ echo -ne "$1\r"
+ local file=$1
+ local name=$(basename $file)
+ pngcrush -d $TMP_DIR -brute -reduce -rem text -rem mkBT \
+ -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
+ mv "$TMP_DIR/$name" "$file"
+}
+
+function sanitize_dir {
+ local dir=$1
+ for f in $(find $dir -name "*.png"); do
+ sanitize_file $f
+ done
+}
+
+if [ ! -e ../.gclient ]; then
+ echo "$0 must be run in src directory"
+ exit 1
+fi
+
+# Make sure we have pngcrush installed.
+dpkg -s pngcrush > /dev/null 2>&1
+if [ "$?" != "0" ]; then
+ read -p "Couldn't fnd pngcrush. Do you want to install? (y/n)"
+ [ "$REPLY" == "y" ] && sudo apt-get install pngcrush
+ [ "$REPLY" == "y" ] || exit
+fi
+
+# Create tmp directory for crushed png file.
+TMP_DIR=$(mktemp -d)
+
+# Make sure we cleanup temp dir
+trap "rm -rf $TMP_DIR" EXIT
+
+# If no arguments passed, sanitize all directories.
+DIRS=$*
+set ${DIRS:=$ALL_DIRS}
+
+for d in $DIRS; do
+ echo "Sanitizing png files in $d"
+ sanitize_dir $d
+ echo
+done
+
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698