SVG to raster conversion.

J

J. Cliff Dyer

Does anybody know a good solution (preferably in python) for rasterizing
SVG or other vector graphics.

I'm thinking something like

vector_image = SVGFile(path_to_image)
raster_image = vector_image.rasterize(format, (width, height), dpi)
raster_image.write(out_file)

Thanks for any pointers you might have.
 
S

Stefan Behnel

J. Cliff Dyer said:
Does anybody know a good solution (preferably in python) for rasterizing
SVG or other vector graphics.

I'm thinking something like

vector_image = SVGFile(path_to_image)
raster_image = vector_image.rasterize(format, (width, height), dpi)
raster_image.write(out_file)

Thanks for any pointers you might have.

The GIMP can do it, and you can even program it in Python.

Stefan
 
J

J. Cliff Dyer

Stefan said:
The GIMP can do it, and you can even program it in Python.

Stefan
Thanks. I can't find a gimp-python package for gimp-2.x anywhere
though. Do
es such a thing exist?
 
L

Laurent Pointal

J. Cliff Dyer a écrit :
Does anybody know a good solution (preferably in python) for rasterizing
SVG or other vector graphics.

I'm thinking something like

vector_image = SVGFile(path_to_image)
raster_image = vector_image.rasterize(format, (width, height), dpi)
raster_image.write(out_file)

Thanks for any pointers you might have.

Another link to complement other replies:

Maybe witgh Cairo:

Library:
http://cairographics.org/

SVG support:
http://cairographics.org/manual/cairo-SVG-Surfaces.html

Python binding:
http://cairographics.org/bindings/


A+

Laurent.
 
P

Paul Boddie

Thanks. I can't find a gimp-python package for gimp-2.x anywhere
though. Does such a thing exist?

I noticed that my copy of The GIMP has Python extensions, and looking
at the package details...

http://packages.ubuntu.com/feisty/graphics/gimp-python

....I can see that the gimp-python capabilities are provided by the
source distribution for The GIMP itself. Perhaps you need to either
install a package such as gimp-python for your operating system
distribution or to configure and build The GIMP from source
appropriately: I imagine that there's an --enable-python option (or
something similar) for the configure script which has to find your
Python installation in order for the bindings/extensions to be built.

Paul

P.S. For batch conversion of SVG images I've successfully used the
ksvgtopng program supplied with KDE.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top