การครอบตัดไฟล์ PSD ขณะแปลงเป็น PNG
Contents
[
Hide
]
ด้วย Aspose.PSD for Java, นักพัฒนาสามารถครอบตัดรูปภาพ PSD ขณะแปลงเป็นรูปแบบราสเตอร์ หัวข้อนี้อธิบายวิธีการโหลดรูปภาพที่มีอยู่, ครอบตัดและแปลงเป็นรูปแบบราสเตอร์
การครอบตัดไฟล์ PSD ขณะแปลงเป็น PNG
ตัวอย่างโค้ดด้านล่างแสดงวิธีการครอบตัดรูปภาพ PSD ขณะแปลงเป็น PNG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dataDir = Utils.getDataDir(CropPSDFile.class) + "Conversion/"; | |
// Implement correct Crop method for PSD files. | |
String sourceFileName = dataDir + "1.psd"; | |
String exportPathPsd = dataDir + "CropTest.psd"; | |
String exportPathPng = dataDir + "CropTest.png"; | |
try (RasterImage image = (RasterImage) Image.load(sourceFileName)) { | |
image.crop(new Rectangle(10, 30, 100, 100)); | |
image.save(exportPathPsd, new PsdOptions()); | |
PngOptions options = new PngOptions(); | |
options.setColorType(PngColorType.TruecolorWithAlpha); | |
image.save(exportPathPng, options); | |
} |