Installation

First download the latest release.

To install simply copy the files
* android_multires.py
* android_multires_export.inx

To your Inkscape extensions folder. You can install it in the shared extension folder or your personal
extension folder.

To create nine-patch images you will also need ImageMagick installed and in your path.
You can get this from the ImageMagick website
Note you will probably need to restart after installing ImageMagick so Inkscape can pick up the changes to your path.

Windows

The shared (system wide) extension directory will be something like
C:\Program Files (x86)\Inkscape\share\extensions

The path to your user extension directory will be something like
C:\Users\<user>\AppData\Roaming\inkscape\extensions
or %AppData%\Roaming\inkscape\extensions

OS X

The easiest way to install Image Magick is with MacPorts assuming you have ports installed and working installation should be as simple as
sudo port install ImageMagick

Then copy the extension files to
~/.config/inkscape/extensions
or
Inkscape.app/Contents/Resources/extensions/
(You can get to this by right clicking on Inkscape in Finder and clicking Show Package Contents)

Unfortunately with Lion and Mountain Lion there are some issues getting Python extensions to run. You can see some work arounds here https://answers.launchpad.net/inkscape/+question/194132. I ended up installing the experimental native build from http://inkscape.13.n6.nabble.com/Mac-OSX-0-48-4-RC3-td4965976.html which works for me.

Useage

To export one resource at multiple resolutions draw the image the set the page to the border of your image, you can do this easily through File -> Document Properties -> Resize page to content -> Resize to drawing or selection.

Then from the Extensions menu choose Export -> Android PNGs...

You will be prompted for the following information
  • Directory path This is the resources directory of your project, the images will be exported to sub-directories called Drawable-mdpi, Drawable-hdpi etc.
  • Create directory Tick to create the resources directory if it doesn't exist
  • Leafname This is the leafname of your png and ultimately the id of your asset so something like cool_button.png
  • mdpi output width This is the width of PNG to output to at Android's 'native' mdpi resolution. Any other assets will be rendered at a resolution proportional to this
  • Export generic Drawable Export an mdpi version to the 'Drawable' folder - this is Android's fallback folder so it's sensible to put something in here
  • Export to... Tick which of the Android resolutions you want to export to
  • Create a nine patch Tick to create a .9.png 9 patch image

To create a nine patch PNG draw four black rectangles outside the page border not touching the page. When the extension exports the image it will take the outermost row and column of pixels of the whole drawing and glue them to the page edges.

Draw your borders like this

ExportDialog.png

The exported image will be

greybutton.9.png

Which you can see in Android's nine patch tool has the correct stretch regions

NinePatchTool.png

Last edited Feb 7, 2013 at 10:26 AM by MarkDaniel, version 8

Comments

No comments yet.