Recorte de Arquivo PSD ao Converter para PNG
Contents
[
Hide
]
Usando o Aspose.PSD para Java, os desenvolvedores podem recortar a imagem PSD ao convertê-la para formato raster. Este tópico explica a abordagem para carregar imagens existentes, recortá-las e convertê-las para formato raster.
Recorte de Arquivo PSD ao Converter para PNG
O código de exemplo fornecido abaixo demonstra como recortar a imagem PSD ao convertê-la para 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); | |
} |