Commit fc47e9ec authored by oshima@chromium.org's avatar oshima@chromium.org

a utility script to pngcrush png files

BUG=150046
TEST=none
NOTRY=true

Review URL: https://chromiumcodereview.appspot.com/11825019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176157 0039d316-1c4b-4281-b951-d872f2087c98
parent fd4bbfc3
#!/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
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment