操作Adobe Illustrator格式

将AI文件导出为PSD

使用Aspose.PSD for Java,开发人员可以将Adobe Illustrator文件转换为PSD格式。本主题解释了加载现有Adobe Illustrator文件并使用 PsdOptions 类将其转换为PSD 的方法。

将Adobe Illustrator文件转换为PSD的步骤如下所示:

  • 创建 AiImage 类的实例,并使用 Image 类的 Load 方法加载图像
  • 创建 PsdOptions 类的实例
  • 使用目标路径和 PsdOptions 类的实例调用 AiImage.Save 方法

以下提供的示例代码演示了如何将Adobe Illustrator导出为PSD。

String dataDir = Utils.getDataDir(AIToPSD.class) + "AI/";
String sourceFileName = dataDir + "34992OStroke.ai";
String outFileName = dataDir + "34992OStroke.psd";
try (AiImage image = (AiImage) Image.load(sourceFileName)) {
PsdOptions options = new PsdOptions();
image.save(outFileName, options);
}

将AI文件导出为JPEG

使用Aspose.PSD for Java,开发人员可以将Adobe Illustrator文件转换为JPEG格式。本主题解释了加载现有AI文件并使用 JpegOptions 类将其转换为JPEG 的方法。

将Adobe Illustrator文件转换为JPEG的步骤如下所示:

  • 创建 AiImage 的实例,并使用 Image 类的 Load 方法加载图像
  • 创建 JpegOptions 类的实例
  • 设置图像质量
  • 使用目标路径和 JpegOptions 类的实例调用 AiImage.save 方法

以下提供的示例代码演示了如何将AI导出为JPEG。

String dataDir = Utils.getDataDir(AIToJPG.class) + "AI/";
String sourceFileName = dataDir + "34992OStroke.ai";
String outFileName = dataDir + "34992OStroke.jpg";
try (AiImage image = (AiImage)Image.load(sourceFileName)) {
JpegOptions options = new JpegOptions();
options.setQuality(85);
image.save(outFileName, options);
}

将AI文件导出为GIF

Aspose.PSD for Java提供了 AiImage 类来加载Adobe Illustrator文件,并可用于将Adobe Illustrator文件导出为GIF格式。该示例演示了如何使用Aspose.PSD for Java API将AI文件导出为GIF图像。

String dataDir = Utils.getDataDir(AIToGIF.class) + "AI/";
String sourceFileName = dataDir + "34992OStroke.ai";
String outFileName = dataDir + "34992OStroke.gif";
try (AiImage image = (AiImage) Image.load(sourceFileName)) {
GifOptions options = new GifOptions();
options.setDoPaletteCorrection(false);
image.save(outFileName, options);
}

将AI文件导出为PNG

使用Aspose.PSD for Java,开发人员可以将Adobe Illustrator文件转换为PNG格式。本主题解释了加载现有Adobe Illustrator文件并使用 PngOptions 类将其转换为PNG 的方法。

将AI文件转换为PNG的步骤如下所示:

  • 创建 AiImage 的实例,并使用 Image 类的 Load 方法加载图像
  • 创建 PngOptions 类的实例
  • 设置颜色类型
  • 使用目标路径和 PngOptions 类的实例调用 AiImage.save 方法

以下提供的示例代码演示了如何将Adobe Illustrator转换为PNG。

String dataDir = Utils.getDataDir(AIToPNG.class) + "AI/";
String sourceFileName = dataDir + "34992OStroke.ai";
String outFileName = dataDir + "34992OStroke.png";
try (AiImage image = (AiImage) Image.load(sourceFileName)) {
PngOptions options = new PngOptions();
options.setColorType(PngColorType.TruecolorWithAlpha);
image.save(outFileName, options);
}

将AI文件导出为TIFF

Aspose.PSD for Java提供了 AiImage 类来加载Adobe Illustrator文件,并可用于将AI文件导出为TIFF格式。该示例演示了如何使用Aspose.PSD for Java API将Adobe Illustrator文件导出为TIFF图像。

String dataDir = Utils.getDataDir(AIToPSD.class) + "AI/";
String sourceFileName = dataDir + "34992OStroke.ai";
String outFileName = dataDir + "34992OStroke.tiff";
try (AiImage image = (AiImage) Image.load(sourceFileName)) {
image.save(outFileName, new TiffOptions(TiffExpectedFormat.TiffDeflateRgba));
}

将AI文件导出为PDF

Aspose.PSD for Java提供了 AiImage 类来加载Adobe Illustrator文件,并可用于将AI文件导出为PDF格式。该示例演示了如何使用Aspose.PSD for Java API将Adobe Illustrator文件导出为PDF图像。

String dataDir = Utils.getDataDir(AIToPDF.class) + "AI/";
String sourceFileName = dataDir + "34992OStroke.ai";
String outFileName = dataDir + "34992OStroke.pdf";
try (AiImage image = (AiImage) Image.load(sourceFileName)) {
PdfOptions options = new PdfOptions();
image.save(outFileName, options);
}