pyninepatch is a python library and command line tool for rendering android-style 9-patch images. (see: http://developer.android.com/guide/topics/graphics/2d-graphics.html)
pyninepatch requires the Python Imaging Library (http://pypi.python.org/pypi/PIL/).
- images with multiple stretchable areas may end up rendering one or two pixels short due to rounding errors.
- it's not super efficient.
$ python ninepatch.py myninepatch.9.png --size 800x600
>>> import ninepatch, Image
>>> np = ninepatch.NinePatch("myninepatch.9.png")
>>> np.render((800,600)).show()
$ python ninepatch.py myninepatch.9.png --content mycontent.png --output output.png
>>> import ninepatch, Image
>>> np = ninepatch.NinePatch("myninepatch.9.png")
>>> img = np.render_around(Image.open("mycontent.png"))
>>> img.save("output.png")