[Image-SIG] vector graphics Q

Fredrik Lundh fredrik at pythonware.com
Sun Oct 16 18:03:00 CEST 2005


Dmitry (Dima) Strakovsky wrote:

> My question is perhaps related to Fredrik earlier post. I read API doc
> (understood about 30%)
>
> I am basically looking for a way to manupulate vector graphics in
> Python. So far I have been reading up on SVG and looking at the output
> from Illustrator and Inkscape (Adobe seems to throw a whole bunch of
> proprietary stuff into the files, surprise?not) The images for this
> particular project are going to be generated in Illustrator (the program
> I am most familiar with) and probably cleaned up with another utility
> (possibly python script), after which I was going to do a fair amount of
> manipulation (hopefully python script) and the final output goes to the
> printer (rastered.)
>
> Fredrick does your lib work with SVG?

aggdraw and PIL only provide a small part of the full "graphics application"
stack.  a full "stack" (e.g. Illustrator) might look like this:

    1. a user interface
    2. a data model that represents the drawing
    3. an I/O library that can be used to store the drawing on disk
    4. a rendering system

in your case, you want to replace the user interface with scripts, so you
need a "stack" that looks like this:

    1. a script engine interface
    2. a data model that represents the drawing
    3. an I/O library that can be used to store the drawing on disk
    4. a rendering system

the aggdraw library provides a (somewhat limited) implementation of 4,
and some support for 3 (it can parse SVG path descriptors), but nothing
more than that.

if aggdraw/PIL/Python is a realistic approach depends on what kind of
drawings you will work on, and what you need to do it with them.  I've
been using the following toolchain for a couple of projects:

    1. draw in illustrator
    2. if necessary, convert to outlines
    3. save as SVG
    4. load into element structure using ElementTree:
            http://effbot.org/zone/element-index.htm
    5. manipulate element structure
    6. render relevant parts using aggdraw
    7. save using PIL

this is quite useful for simple drawings, such as icons and other symbols,
but might need a lot of work if you want to support more illustrator/SVG
features (and/or get rid of the second step).

</F>





More information about the Image-SIG mailing list