0

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

domipoke
  • 15
  • 1
  • 4
  • 1
    Please repeat [on topic](https://stackoverflow.com/help/on-topic) and [how to ask](https://stackoverflow.com/help/how-to-ask) from the [intro tour](https://stackoverflow.com/tour). “Show me how to solve this coding problem” is not a Stack Overflow issue. We expect you to make an honest attempt, and *then* ask a *specific* question about your algorithm or technique. Stack Overflow is not intended to replace existing documentation and tutorials. – Prune Apr 28 '21 at 23:01
  • 1
    does this help? https://stackoverflow.com/questions/6589358/convert-svg-to-png-in-python – Sylvan Franklin Apr 28 '21 at 23:02
  • 1
    Does this answer your question? [Convert SVG to PNG in Python](https://stackoverflow.com/questions/6589358/convert-svg-to-png-in-python) – cigien Apr 28 '21 at 23:37

1 Answers1

2

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")
Eduardo Jiménez
  • 351
  • 3
  • 13