Java APIソリューションを使用したPNGからEPSへの変換

概要

この記事では、Java を使用して PNG を EPS に変換する方法 について説明します。以下のトピックを取り上げます。

Java で画像を EPS へ

Java を使って BMP、JPG、GIF などの他の形式から EPS に変換する方法については、以下の記事で解説しています。

Java PNG から EPS への変換

Aspose.Page PNGからEPSへの変換の品質を確認し、無料のオンラインPNG to EPS Converterで結果を表示し、その後、EPS Viewerで結果のEPSファイルを表示できます。


Aspose.Page for Java の PNG から EPS へのコンバーターを使用すると、Java 仮想マシンが動作するあらゆる OS で PNG 画像を Encapsulated PostScript (EPS) ファイルに変換できます。
手順:Java での PNG から EPS へのコンバーター API コード

PNG から EPS への変換は、以下の 2 つの手順で実行できます。

  1. PsSaveOptions のインスタンスを作成します。
  2. PsDocument の静的メソッドを使用します。 saveImageToEps メソッドには、PNG 画像を EPS 形式に保存するための最も簡単な方法を提供するために、4 つの変更が加えられています。

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でPNGファイルをEPSファイルに保存するためにBufferedImageオブジェクトと文字列を使用する

以下の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);

JavaでPNGファイルをEPSファイルに保存するためにBufferedImageオブジェクトとストリームを使用する

以下の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 to EPS Converter で、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.