Answer the question
In order to leave comments, you need to log in
How to convert svg to png in python 3 on windows 8.1?
Hello! I'm trying to convert an SVG file to PNG in Python 3.
I'm trying to use the cairosvg library. I install it through the command line using pip, everything is installed. OS - Windows 8.1.
I run the python file . There are import cairosvg
4 errors in the code of the cairosvg itself.
What am I doing wrong? How to properly install cairosvg on Windows 8.1
Or tell me the library and its method, with which you can convert svg to png.
Thanks to.
Answer the question
In order to leave comments, you need to log in
https://stackoverflow.com/questions/6589358/conver...
import cairo
import rsvg
img = cairo.ImageSurface(cairo.FORMAT_ARGB32, 640,480)
ctx = cairo.Context(img)
## handle = rsvg.Handle(<svg filename>)
# or, for in memory SVG data:
handle= rsvg.Handle(None, str(<svg data>))
handle.render_cairo(ctx)
img.write_to_png("svg.png")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question