I have some icons in SVG format, and want to convert them to Android png drawables, in the following sizes: drawable-mdpi
, drawable-hdpi
, drawable-xhdpi
, drawable-xxhdpi
and drawable-xxxhdpi
.
What's the easiest way to convert an SVG to drawable pngs?
Question might be a bit outdated, but I searched Internet and didn't find any good solution. So I wrote a simple bash script which does conversion of SVG as well as raster image formats.
Here it is: https://gist.github.com/tntclaus/18f4fe7e8540f1cb283d2c7d8ad21d69
Usage:
./generateAndroidDrawables.sh <image.file> <dp>
It requires at least ImageMagic, which on OS X can be installed via brew
or macports
. Unfortunately ImageMagic poorly converts SVG, so I added support of Inkscape. If Inkscape is not installed, script falls back to ImageMagic conversion.