I have some code below that is supposed to convert a SVG image to a PNG. It runs without errors but creates a PNG file that is blank instead of one with the same image as the original SVG. I did find that it is not an error with cairo but more one relating to rsvg, which I got here.
import cairo
import rsvg
img = cairo.ImageSurface(cairo.FORMAT_ARGB32, 640,480)
ctx = cairo.Context(img)
handle= rsvghandler.Handle('example.svg')
handle.render_cairo(ctx)
img.write_to_png("svg.png")
I am using Python 3.6 on Windows 10.
I can't for the life of me figure out why it isn't displaying the correct picture. Any help would be hugely appreciated.
cairo
. When runningpip install cairo
, I getCould not find a version that satisfies the requirement cairo (from versions: )
. When runningpip install pycairo
, I get the errorPackage cairo was not found in the pkg-config search path.Perhaps you should add the directory containing 'cairo.pc' to the PKG_CONFIG_PATH environment variable
. How did you get it? – Bondagepip install [wheelname]
to install it. I don't remember which one worked for me, but I had to try a few before being able to install it correctly. – Lorianne