PSD 이미지를 래스터 포맷으로 변환하기
Contents
[
Hide
]
Aspose.PSD를 사용하여 Java에서 개발자는 PSD 파일 형식을 지원되는 래스터 파일 형식 중 하나로 내보낼 수 있습니다. 이 주제에서는 기존 PSD 파일을 불러와 다양한 래스터 파일 형식으로 내보내는 방법을 설명합니다.
다양한 래스터 파일 형식으로 PSD 이미지 내보내기
아래 제공된 샘플 코드는 PSD를 여러 래스터 파일 형식으로 변환하는 방법을 보여줍니다.
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(PSDToRasterImageFormats.class) + "Conversion/"; | |
String srcPath = dataDir + "sample.psd"; | |
String destName = dataDir + "export"; | |
// Load an existing PSD image as Image | |
try (Image image = Image.load(srcPath)) { | |
// Create an instance of PngOptions class | |
PngOptions pngOptions = new PngOptions(); | |
// Create an instance of BmpOptions class | |
BmpOptions bmpOptions = new BmpOptions(); | |
// Create an instance of GifOptions class | |
GifOptions gifOptions = new GifOptions(); | |
// Create an instance of JpegOptions class | |
JpegOptions jpegOptions = new JpegOptions(); | |
// Create an instance of Jpeg2000Options class | |
Jpeg2000Options jpeg2000Options = new Jpeg2000Options(); | |
// Call the save method, provide output path and export options to convert PSD file to various raster file formats. | |
image.save(destName + ".png", pngOptions); | |
image.save(destName + ".bmp", bmpOptions); | |
image.save(destName + ".gif", gifOptions); | |
image.save(destName + ".jpeg", jpegOptions); | |
image.save(destName + ".jp2", jpeg2000Options); | |
} |