使用 Java API 解决方案将 PNG 转换为 EPS

概述

本文讲解如何使用 Java 将 PNG 转换为 EPS。内容涵盖以下主题:

Java 图像转 EPS

本文涵盖了如何使用 Java 将 BMP、JPG、GIF 等其他格式的图像转换为 EPS。

Java PNG 转 EPS

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


Aspose.Page for Java PNG 转 EPS 转换器允许在任何支持 Java 虚拟机的操作系统上将 PNG 图像转换为封装 PostScript (EPS) 文件。
步骤:Java 语言 PNG 到 EPS 转换器 API 代码

只需执行 2 个步骤即可将 PNG 转换为 EPS:

  1. 创建 PsSaveOptions 的实例。
  2. 使用 PsDocument 的静态方法 saveImageToEpssaveImageToEps 方法有四个修改,为用户提供将 PNG 图像保存为 EPS 的最舒适的方式。

使用字符串在 Java 中将 PNG 保存为 EPS

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

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Java
 2
 3// The path to the documents directory.
 4String dataDir = getDataDir();
 5
 6// Create default options
 7PsSaveOptions options = new PsSaveOptions();
 8
 9// Save PNG image to EPS file
10PsDocument.saveImageAsEps(dataDir + "input1.png", dataDir + "output1.eps", options);

使用 Java 流将 PNG 图像保存为 EPS 图像

以下 Java 代码片段通过流分配输入图像和输出 EPS 文件:

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

在 Java 中使用 BufferedImage 对象和字符串将 PNG 图像保存为 EPS 文件

以下 Java 代码片段中,输入图像由 BufferedImage 对象赋值,输出 EPS 文件由字符串赋值:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Java
 2
 3// The path to the documents directory.
 4String dataDir = getDataDir();
 5
 6// Create default options
 7PsSaveOptions options = new PsSaveOptions();
 8
 9// Create the BufferedImage object from the image file
10BufferedImage png = ImageIO.read(new FileInputStream(dataDir + "input1.png")))
11
12// Save PNG image to EPS file
13PsDocument.saveImageAsEps(png, dataDir + "output1.eps", options);

使用 BufferedImage 对象和流在 Java 中将 PNG 图像保存为 EPS 图像

以下 Java 代码片段中,输入图像由 BufferedImage 对象赋值,输出 EPS 文件由流赋值:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Java
 2
 3// The path to the documents directory.
 4String dataDir = getDataDir();
 5
 6// Create default options
 7PsSaveOptions options = new PsSaveOptions();
 8
 9// Create the BufferedImage object from the image file
10BufferedImage png = ImageIO.read(new FileInputStream(dataDir + "input1.png")))
11
12// Create the output stream for EPS file
13OutputStream outputStream = new FileOutputStream(dataDir + "output1.eps"))
14
15// Save PNG image to EPS file
16PsDocument.saveImageAsEps(png, outputStream, options);

查看 .NET 中 PNG 到 EPS 的转换。

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

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

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.