-
-
Save sadisasha/248f7d8afb61048d8b89 to your computer and use it in GitHub Desktop.
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 | |
if [[ -z "$1" ]]; | |
then | |
echo "No SVG file specified. Exiting." | |
exit -1 | |
fi | |
ispng=$(file $1) | |
echo $ispng | grep -q SVG | |
if [[ $? -ne 0 ]]; | |
then | |
echo "Invalid SVG file. Exiting." | |
exit -2 | |
fi | |
W=(48 72 96 144 192) | |
DPINAME=("mdpi" "hdpi" "xhdpi" "xxhdpi" "xxxhdpi") | |
if [[ -z "$2" ]]; | |
then | |
BASE="ic_launcher" | |
else | |
BASE="$2" | |
fi | |
for ((ii=0;ii<5;ii++)); | |
do | |
echo "Processing $1 for ${DPINAME[$ii]}@${W[$ii]} px" | |
suffix=${DPINAME[$ii]} | |
resroot=`basename $1` | |
dirname=$resroot/res/drawable-${DPINAME[$ii]} | |
mkdir -p "$dirname" | |
fname="$dirname"/"$BASE".png | |
inkscape -z -f=$1 --export-png="$fname" \ | |
-h=${W[$ii]} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment