تبدیل تصویر PSD به فرمت فرعی
Contents
[
Hide
]
با استفاده از Aspose.PSD برای جاوا، توسعه دهندگان می توانند فرمت فایل 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); | |
} |