Ritaglio del file PSD durante la conversione in PNG
Contents
[
Hide
]
Utilizzando Aspose.PSD per Java, gli sviluppatori possono ritagliare l’immagine PSD durante la conversione nel formato raster. Questo argomento spiega l’approccio per caricare immagini esistenti, ritagliarle e convertirle nel formato raster.
Ritaglio del file PSD durante la conversione in PNG
Di seguito è riportato un codice di esempio che dimostra come ritagliare l’immagine PSD durante la conversione in 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); | |
} |