Search code examples
python-3.xsvgpng

Convert a SVG to PNG using python?


I have to convert a .svg file to a .png file.

I don't need a command line.

I'm using python 3.9.2 64-bit

I'm using windows10


Solution

  • You can use the library pyvips

    And use it like this:

    import pyvips
    
    image = pyvips.Image.new_from_file("img.svg", dpi=300)
    image.write_to_file("img.png")