Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Script to scale and create Android images at the correct dpi levels
#!/bin/bash
#Requires ImageMagick to be installed.
#Some builds of ImageMagick on OSX have problems generating the images correctly.
#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.
for f in *.svg;
do
echo "Processing $f"
convert -background none $f ../../drawable-hdpi/${f/.svg}.png
convert -background none $f[66.67%] ../../drawable-mdpi/${f/.svg}.png
convert -background none $f[50%] ../../drawable-ldpi/${f/.svg}.png
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment