使用 Python 将 PNG 转换为 EPS
Contents
[
Hide
Show
]本文将以多种方式讲解如何使用 Python 将 PNG 转换为 EPS。学习所有方法,找到最适合您的方法。
Python PNG 转 EPS
您可以使用免费的在线 PNG 转 EPS 转换器 检查 Aspose.Page PNG 转 EPS 的质量并查看结果,然后使用我们的 EPS 查看器 查看生成的 EPS 文件
只需两步即可将 PNG 图像转换为 EPS 图像:
- 创建 PsSaveOptions 实例。
- 使用 PsDocument 的静态方法 save_image_to_eps。
save_image_to_eps 方法有四处修改,以便用户以最便捷的方式将 PNG 图像保存为 EPS 图像。
在 Python 中使用字符串将 PNG 保存为 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 PNG image as EPS file
10PsDocument.save_image_as_eps(data_dir + "input1.png", data_dir + "output1.eps", options)
在 Python 中使用流将 PNG 保存为 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# Create default options
4options = PsSaveOptions()
5
6# Save the PNG image as EPS file
7PsDocument.save_image_as_eps(inputStream, outputStream, options)
使用 Bitmap 对象和字符串在 Python 中将 PNG 格式保存为 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
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);
在我们的 PNG 到 EPS 转换器 上在线评估 PNG 到 EPS 的转换效果。您可以一次将多个 PNG 图像转换为 EPS 文件,并在几秒钟内下载结果。
您可以从 GitHub 下载示例和数据文件。
其他转换选项: