Skip to content

Instantly share code, notes, and snippets.

@white-gecko
Forked from DDRBoxman/ink_create_images
Created October 18, 2012 21:57
Show Gist options
  • Save white-gecko/3915006 to your computer and use it in GitHub Desktop.
Save white-gecko/3915006 to your computer and use it in GitHub Desktop.
Script to create / scale Android resources from vectors
#!/bin/bash
#Requires Inkscape to be installed.
#This script scales and creates images at the correct dpi level for Android.
#It gets placed in a folder called res/drawable/_source_images/ in your
#Android project along with all your svg files.
#When creating svg files set the image size to the size that you want your hdpi images to be.
#To use simply run the create_images script from its folder and it will generate images for all the svg files.
from=$1
to=${1/.svg}.png
base=../drawable
if test $2; then
to=$2
fi
if test $3; then
base=$base$3
fi
mkdir -p "$base-xhdpi"
mkdir -p "$base-hdpi"
mkdir -p "$base-mdpi"
mkdir -p "$base-ldpi"
echo "Processing $f"
inkscape -d 120 -e "$base-xhdpi/$to" "$from"
inkscape -d 90 -e "$base-hdpi/$to" "$from" # default
inkscape -d 60 -e "$base-mdpi/$to" "$from"
inkscape -d 45 -e "$base-ldpi/$to" "$from"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment