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); | |
} |