使用 Python 将 JPG 转换为 EPS

本文介绍了如何使用 Python 将 JPG 转换为 EPS 的不同方法。学习所有方法,找到最适合您的方法。

Python JPG 转 EPS 转换

您可以使用免费的在线 JPG 转 EPS 转换器 检查 Aspose.Page JPG 转 EPS 的质量并查看结果,然后使用我们的 EPS 查看器 查看生成的 EPS 文件


步骤:Python 中的 JPG 转 EPS 转换器 API 代码

只需两步即可将 JPG 转换为 EPS:

  1. 创建 PsSaveOptions 实例。
  2. 使用 PsDocument 的静态方法 save_image_to_eps

save_image_to_eps 方法有四种修改方式,以便用户以最便捷的方式将 JPG 图像保存为 EPS。

在 Python 中使用字符串将 JPG 保存为 EPS

在以下 Python 代码片段中,输入图像和输出 EPS 文件均通过字符串赋值:

 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)

使用 Python 中的流将 JPG 格式保存为 EPS 格式

以下 Python 代码片段通过流指定了输入图像和输出 EPS 文件:

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)

在 Python 中使用 Bitmap 对象和字符串将 JPG 格式保存为 EPS

以下 Python 代码片段中,输入图像由 aspose.pydrawing.Bitmap 对象分配,输出 EPS 文件由字符串分配:

 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);

在 Python 中使用 Bitmap 对象和流将 JPG 格式保存为 EPS 格式

以下 Python 代码片段中,aspose.pydrawing.Bitmap 对象指定输入图像,流指定输出 EPS 文件:

 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);

请参阅 .NETJava 中的 JPG 到 EPS 转换。

在我们的 JPG 到 EPS 转换器 上在线评估 JPG 到 EPS 的转换效果。您可以一次将多张 JPG 图像转换为 EPS 文件,并在几秒钟内下载结果。

您可以从 GitHub 下载示例和数据文件。

其他转换选项:

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.