Cắt Ghép Tệp PSD Khi Chuyển Đổi Sang PNG
Contents
[
Hide
]
Sử dụng Aspose.PSD cho Java, các nhà phát triển có thể cắt ghép hình ảnh PSD trong quá trình chuyển đổi sang định dạng raster. Chủ đề này giải thích cách tải hình ảnh hiện có, cắt ghép chúng và chuyển đổi sang định dạng raster.
Cắt Ghép Tệp PSD Khi Chuyển Đổi Sang PNG
Bên dưới là đoạn mã minh họa cung cấp cho việc cắt ghép hình ảnh PSD trong quá trình chuyển đổi sang 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); | |
} |