Convert Visio to Image in Python

Microsoft Visio is a popular diagramming and image-processing application used for creating technical and management diagrams. VSDX is the default file format for saving drawing files. In certain cases, we may need to save Visio diagrams as PNG or JPEG images programmatically. Images are easy to understand in many situations where Visio is difficult to grasp. Converting Visio diagrams to images allows sharing your drawings with a wide range of individuals. In this article, we will learn how to convert Visio to image in Python.

This article shall cover the following topics:

  1. Python Visio to Image Converter – Free Download
  2. Convert Visio Diagram to PNG
  3. Convert Visio Diagram to JPG
  4. Save Specific Page of a Visio Diagram as an Image in Python

Python Visio to Image Converter – Free Download

For converting Visio drawings to Images, we will be using the Aspose.Diagram for Python. The API allows creating, editing, converting, and processing MS Visio diagrams. It also makes it easier to manipulate the supported Visio file formats with easy-to-use properties and methods.

The API exposes the Diagram class, which is the root element of the Visio objects hierarchy. It provides the Save(string filename, SaveFileFormat format) method for saving the diagram to the file in a specified format. Additionally, the API provides the SaveFileFormat enumeration for selecting the format for saving diagrams. We can also specify additional save options when rendering diagram pages to images using the ImageSaveOptions class.

Please either download the package or install the API from PyPI using the following pip command in the console:

pip install aspose-diagram-python 

Convert Visio to PNG Image in Python

We can easily save a Visio diagram as a PNG by following the steps given below:

  1. Load an input Visio file using the Diagram class.
  2. Call the save() method to save it as an Image. It takes the output Image file path and SaveFileFormat.PNG as arguments.

The following code sample shows how to convert a Visio diagram to a PNG in Python.

Convert Visio to Image in Python

Convert Visio to PNG Image using Python.

Convert Visio to JPG Image in Python

Similarly, we can convert a Visio diagram to a JPG image by following the steps given below:

  1. Load an input Visio file using the Diagram class.
  2. Call the save() method with the output Image file path and SaveFileFormat.JPEG as arguments.

The following code sample shows how to convert a Visio diagram to a JPG in Python.

Save Specific Page of Visio as Image in Python

We can also specify image save options and save any specific page of a Visio diagram as an image by following the steps given below:

  1. Firstly, load an input Visio file using the Diagram class.
  2. Next, create an instance of the ImageSaveOptions class.
  3. After that, specify the page_index to save as an image.
  4. Finally, call the save() method to save it as an Image. It takes the output Image file path and the ImageSaveOptions as arguments.

The following code sample shows how to convert a specific page of a Visio diagram to an image in Python.

Save Specific Page of Visio as Image in Python

Save Specific Page of Visio as Image in Python.

Get Free Temporary License

You can get a free temporary license to try the library without evaluation limitations.

Conclusion

In this article, we have learned how to:

  • load an existing Visio diagram file;
  • specify image save options;
  • save Visio diagrams as PNG or JPEG/JPG images in Python.

Besides converting Visio to image in Python, you can learn more about Aspose.Diagram for Python API using documentation. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also