รูปแบบ AI (Adobe Illustrator)
AI, งานศิลปะ Adobe Illustrator, แทนภาพเวกเตอร์แบบหน้าเดียวในรูปแบบ EPS หรือ PDF ซึ่งมีโครงสร้างไฟล์ AI ขึ้นอยู่กับเวอร์ชันของมัน
Aspose.PSD รองรับรุ่น AI ต่อไปนี้ในขณะนี้ (การรองรับเต็มรูปแบบของ AI อยู่ในแผนผลิตภัณฑ์):
- AI เวอร์ชัน 3
- AI เวอร์ชัน 8
คุณสามารถส่งออกไฟล์ AI ของเวอร์ชันที่รองรับไปยังรูปแบบที่รองรับโดย Aspose.PSD ได้ ตัวอย่างเช่น คุณสามารถส่งออกไฟล์ AI โปรแกรมให้ Psd, Png, Jpeg, Gif, Bmp, Tiff file formats
ส่วนรหัสตัวอย่างด้านล่างแสดงวิธีการส่งออกไฟล์ AI เป็น PSD ด้วย API จัดการรูปแบบไฟล์
// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET | |
{ | |
@"34992OStroke", | |
@"rect2_color", | |
}; | |
for (int i = 0; i < sourcesFiles.Length; i++) | |
{ | |
string name = sourcesFiles[i]; | |
string sourceFileName = dataDir + name + ".ai"; | |
string outFileName = dataDir + name + ".psd"; | |
using (AiImage image = (AiImage)Image.Load(sourceFileName)) | |
{ | |
ImageOptionsBase options = new PsdOptions(); | |
image.Save(outFileName, options); | |
} | |
} |
ตัวอย่างของความสามารถในการส่งออกปัจจุบันของไฟล์ AI
ตัวอย่าง | รายละเอียด |
---|---|
![]() |
การส่งออกไฟล์ AI รวมถึงความสามารถ ในการระบาย primitives Postscript ด้วยขนาดและเส้นปากกาที่แตกต่าง ด้วยน้ำหนักที่กำหนดเอง |
![]() |
การเรนเดอร์เส้นทางซับซ้อนจากไฟล์ AI โดยใช้ API C# โดยไม่มี Adobe Illustrator |
คุณสมบัติเพิ่มเติมในการจัดการ AI ผ่าน API ของรูปแบบไฟล์
Aspose.PSD มีความสามารถในการจัดการเลเยอร์และภาพ Raster จากไฟล์ AI ทั้งหมดคุณสมบัติเหล่านี้จะทำงานเฉพาะกับเวอร์ชันของไฟล์ Adobe Illustrator ที่รองรับ
รหัสตัวอย่างแสดงวิธีการคุณสามารถจัดการภาพ Raster จากส่วนไฟล์ AI
// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET | |
void AssertIsTrue(bool condition, string message) | |
{ | |
if (!condition) | |
{ | |
throw new FormatException(message); | |
} | |
} | |
string sourceFile = dataDir + "sample.ai"; | |
using (AiImage image = (AiImage)Image.Load(sourceFile)) | |
{ | |
AiLayerSection layer = image.Layers[0]; | |
AssertIsTrue(layer.RasterImages != null, "RasterImages property should be not null"); | |
AssertIsTrue(layer.RasterImages.Length == 1, "RasterImages property should contain exactly one item"); | |
AiRasterImageSection rasterImage = layer.RasterImages[0]; | |
AssertIsTrue(rasterImage.Pixels != null, "rasterImage.Pixels property should be not null"); | |
AssertIsTrue(rasterImage.Pixels.Length == 100, "rasterImage.Pixels property should contain exactly 100 items"); | |
AssertIsTrue((uint)rasterImage.Pixels[99] == 0xFFB21616, "rasterImage.Pixels[99] should be 0xFFB21616"); | |
AssertIsTrue((uint)rasterImage.Pixels[19] == 0xFF00FF00, "rasterImage.Pixels[19] should be 0xFF00FF00"); | |
AssertIsTrue((uint)rasterImage.Pixels[10] == 0xFF01FD00, "rasterImage.Pixels[10] should be 0xFF01FD00"); | |
AssertIsTrue((uint)rasterImage.Pixels[0] == 0xFF0000FF, "rasterImage.Pixels[0] should be 0xFF0000FF"); | |
AssertIsTrue(Math.Abs(0.999875 - rasterImage.Width) < DefaultTolerance, "rasterImage.Width should be 0.99987"); | |
AssertIsTrue(Math.Abs(0.999875 - rasterImage.Height) < DefaultTolerance, "rasterImage.Height should be 0.99987"); | |
AssertIsTrue(Math.Abs(387 - rasterImage.OffsetX) < DefaultTolerance, "rasterImage.OffsetX should be 387"); | |
AssertIsTrue(Math.Abs(379 - rasterImage.OffsetY) < DefaultTolerance, "rasterImage.OffsetY should be 379"); | |
AssertIsTrue(Math.Abs(0 - rasterImage.Angle) < DefaultTolerance, "rasterImage.Angle should be 0"); | |
AssertIsTrue(Math.Abs(0 - rasterImage.LeftBottomShift) < DefaultTolerance, "rasterImage.LeftBottomShift should be 0"); | |
AssertIsTrue(Math.Abs(0 - rasterImage.ImageRectangle.X) < DefaultTolerance, "rasterImage.ImageRectangle.X should be 0"); | |
AssertIsTrue(Math.Abs(0 - rasterImage.ImageRectangle.Y) < DefaultTolerance, "rasterImage.ImageRectangle.Y should be 0"); | |
AssertIsTrue(Math.Abs(10 - rasterImage.ImageRectangle.Width) < DefaultTolerance, "rasterImage.ImageRectangle.Width should be 10"); | |
AssertIsTrue(Math.Abs(10 - rasterImage.ImageRectangle.Height) < DefaultTolerance, "rasterImage.ImageRectangle.Height should be 10"); | |
} |