Convert JPG to EPS using Python

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

Python JPG to EPS Conversion

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


Steps: JPG to EPS Converter API Code in Python

It is necessary to take just 2 steps in order to perform JPG 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 JPG images as EPS.

Using strings for saving JPG 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 JPEG image as EPS file
10PsDocument.save_image_as_eps(data_dir + "input1.jpg", data_dir + "output1.eps", options)

Using streams for saving JPG to EPS in Python

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

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

Using a Bitmap object and a string for saving JPG 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 the 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
10jpg = aspose.pydrawing.Bitmap(open(dataDir + "input1.jpg")))
11
12# Save the JPG image as EPS file
13PsDocument.save_image_as_eps(jpg, dataDir + "output1.eps", options);

Using a Bitmap object and a stream for saving JPG 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 the 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
10jpg = aspose.pydrawing.Bitmap(open(dataDir + "input1.jpg")))
11
12# Save JPG image to output stream
13PsDocument.save_image_as_eps(jpg, outputStream, options);

See JPG to EPS conversion in .NET, Java.

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

You can download examples and data files from GitHub.

Other conversion options:

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.