将 AI 转换为 Png
使用 Aspose.PSD,您可以将支持的 AI 文件版本转换为 Png 格式。Png 是一种支持无损数据压缩的光栅图形文件格式。此外,Png 支持透明度。可以在服务器上自动执行对 Ai 文件的栅格化。要导出 Ai 文件,您需要使用以下代码片段:
以下提供的示例代码演示了如何通过编程方式将 AI 文件导出为 Png 格式。
// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET | |
string[] sourcesFiles = new string[] | |
{ | |
@"34992OStroke", | |
@"rect2_color", | |
}; | |
for (int i = 0; i < sourcesFiles.Length; i++) | |
{ | |
string name = sourcesFiles[i]; | |
string sourceFileName = dataDir + name + ".ai"; | |
string outFileName = dataDir + name + ".png"; | |
using (AiImage image = (AiImage)Image.Load(sourceFileName)) | |
{ | |
ImageOptionsBase options = new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha }; | |
image.Save(outFileName, options); | |
} | |
} |
使用 Aspose.PSD,您可以指定 Png 压缩级别。您可以使用 Png 渐进式压缩并更改 Png 文件的颜色类型。Png 选项具有不同的属性,适用于任何 Ai 导出情况。
Ai 格式支持更改矢量数据的不透明度,而 Png 支持半透明性,因此这两种格式的组合可以帮助您进行文件格式自动化。
当前将 AI 文件导出为 Png 的示例 能力
示例 | 描述 |
---|---|
![]() |
导出 AI 文件包括以下能力 以不同的填充和笔触呈现 Postscript 原语 以及任意自定义宽度。 |
![]() |
使用 C# API 从 AI 文件渲染复杂路径 而无需 Adobe Illustrator。 |