Created
December 12, 2014 02:43
-
-
Save niqueco/af29ad205fbdf9d58d13 to your computer and use it in GitHub Desktop.
Utility to "tint" an Android nine-patch file without breaking it using ImageMagick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
set -e | |
if [ $# -lt 2 ]; then | |
echo Usage: >&2 | |
echo " $0 color image..." >&2 | |
exit 1 | |
fi | |
color="$1" | |
shift | |
for fn in "$@"; do | |
g=$(echo $( file "$fn" | sed -nre 's/^.* ([0-9]+) x ([0-9]+),.*$/\1 - 2\n\2 - 2/p' | bc ) | tr " " x) | |
tmp="$(mktemp)" | |
convert "$fn" -gravity center -region "$g" -fill "$color" -fuzz 90% -opaque white "$tmp" | |
mv "$tmp" "$fn" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment