Convert SVG to PNG in Python

In certain cases, you have to perform back and forth conversion of image formats programmatically based on your requirements. For example, JPG to PNG, SVG to PNG, and so on. SVG (Scalable Vector Graphics) is one of the commonly used formats to render two-dimensional images. On the other hand, PNG is also a well known and widely used image format. So let’s have a look at how to convert SVG images to PNG in Python.

Python Library to Convert SVG to PNG - Free Download

To convert SVG images to PNG, we will use Aspose.Words for Python. It is a powerful Python library that lets you process and manipulate text and image files seamlessly. You can install the library in your Python application from PyPI using the following pip command.

> pip install aspose-words

Steps to Convert SVG to PNG in Python

The following are the steps to convert an SVG to PNG using Aspose.Words for Python.

  • Create a new document.
  • Insert SVG image to the document.
  • Apply page settings to the document.
  • Save document as PNG image.

Convert SVG to PNG in Python

Let’s now have a look at how to transform the above-mentioned steps into the Python code using Aspose.Words for Python. The following steps demonstrate SVG to PNG conversion in Python.

  • Create an object of Document class.
  • Create an object of DocumentBuilder class and initialize it with Document object.
  • Insert SVG image to the document using DocumentBuilder.insert_image() method.
  • Apply page settings to the document using DocumentBuilder.page_setup property.
  • Save document as PNG image using method.

The following code sample shows how to save an SVG as PNG in Python.

Python SVG to PNG Converter - Get a Free License

You can get a free temporary license to use Aspose.Words for Python without evaluation limitations.


In this article, you have learned how to convert an SVG to PNG programmatically in Python. You can simply install the library and use the provided code sample to convert the SVG files to PNG seamlessly in your Python applications. In addition, you can learn more about Aspose.Words using the documentation. Also, you can share your questions or queries via our forum.

See Also