Reputation: 742
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?
Upvotes: 15
Views: 15379
Reputation: 929
I've seen this recently, I saw answers but they are difficult.
This online tool too much easier https://appicon.co/
You can convert any image to android multi density or IOS
Upvotes: 2
Reputation: 184
There is an online tool I worked on which can convert an svg image to different platforms, including android.
By default it will convert it to Android drawable, so you need to change the Android setting from auto to png and it will create all the densities you need.
Please note that the mdpi resolution will have the same size as the svg. So you may need to change the width/height parameters to enlarge to output. Or your can try the service for free which will let you specify the output resolution of the mdpi version.
Upvotes: 7
Reputation: 355
This is too late but I found this Github Java project, named SVG to PNG Converter, really quick and easy to convert SVG files to Android compatible png drawables.
Upvotes: 2
Reputation: 3268
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.
Upvotes: 9