Convert PNG to EPS using Python

This article explains how to convert PNG to EPS using Python in different ways. Learn all to find the one that suits you best.

Python PNG to EPS Conversion

You can check the quality of Aspose.Page PNG to EPS conversion and view the results via free online PNG to EPS Converter and than view the resulting EPS file with our EPS Viewer


Steps: PNG to EPS Converter API Code in Python

It is necessary to take just 2 steps in order to perform PNG to EPS conversion:

  1. Create an instance of PsSaveOptions.
  2. Use static method save_image_to_eps of PsDocument.

The save_image_to_eps method has four modifications to provide a user with the most comfortable way to save PNG image to EPS.

Using strings for saving PNG to EPS in Python

In the following Python code snippet the input image and the output EPS file are assigned by strings:

 1# For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Python-.NET
 2
 3# The path to the documents directory.
 4data_dir = Util.get_data_dir_working_with_image_conversion()
 5
 6# Create default options
 7options = PsSaveOptions()
 8
 9# Save the PNG image as EPS file
10PsDocument.save_image_as_eps(data_dir + "input1.png", data_dir + "output1.eps", options)

Using streams for saving PNG as EPS in Python

In the following Python code snippet an input image and an output EPS file are assigned by streams:

1# For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Python-.NET
2
3# Create default options
4options = PsSaveOptions()
5
6# Save the PNG image as EPS file
7PsDocument.save_image_as_eps(inputStream, outputStream, options)

Using Bitmap objects and strings for saving PNG to EPS in Python

In the following Python code snippet an input image is assigned by the aspose.pydrawing.Bitmap object and the output EPS file is assigned by a string:

 1# For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Python-.NET
 2
 3# The path to the documents directory.
 4data_dir = Util.get_data_dir_working_with_image_conversion()
 5
 6# Create default options
 7options = PsSaveOptions()
 8
 9# Create the Bitmap object from the image file
10png = aspose.pydrawing.Bitmap(open(dataDir + "input1.png")))
11
12# Save the PNG image to EPS file
13PsDocument.save_image_as_eps(png, dataDir + "output1.eps", options);

Using a Bitmap object and a stream for saving PNG to EPS in Python

In the following Python code snippet an input image is assigned by the aspose.pydrawing.Bitmap object and the output EPS file is assigned by stream:

 1# For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Python-.NET
 2
 3# The path to the documents directory.
 4data_dir = Util.get_data_dir_working_with_image_conversion()
 5
 6# Create default options
 7options = PsSaveOptions()
 8
 9# Create the Bitmap object from the image file
10png = aspose.pydrawing.Bitmap(open(dataDir + "input1.png")))
11
12# Save PNG image to output stream
13PsDocument.save_image_as_eps(png, outputStream, options);

See PNG to EPS conversion in .NET, Java.

Evaluate PNG to EPS conversion online on our PNG to EPS Converter. You can convert several PNG image to EPS files at once and dowload results in a few seconds.

You can download examples and data files from GitHub.

Other conversion options:

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.