Apply Masking

Support of Layer Mask

This article shows how to support layer of mask for PSD images than save those images. The code snippet has been provided below.

String dataDir = Utils.getDataDir(SupportOfLayerMask.class) + "PSD/";
// Export of the psd with complex mask
String sourceFileName = dataDir + "MaskComplex.psd";
String exportPath = dataDir + "MaskComplex.png";
try (PsdImage im = (PsdImage) Image.load(sourceFileName)) {
// Export to PNG
PngOptions saveOptions = new PngOptions();
saveOptions.setColorType(PngColorType.TruecolorWithAlpha);
im.save(exportPath, saveOptions);
}

Support of Clipping Mask

This article shows how to support clipping mask in a PSD file with Aspose.PSD. The code snippet has been provided below.

String dataDir = Utils.getDataDir(SupportOfClippingMask.class) + "PSD/";
// Exposure layer editing
// Export of the psd with complex clipping mask
String sourceFileName = dataDir + "ClippingMaskComplex.psd";
String exportPath = dataDir + "ClippingMaskComplex.png";
try (PsdImage im = (PsdImage) Image.load(sourceFileName)) {
// Export to PNG
PngOptions saveOptions = new PngOptions();
saveOptions.setColorType(PngColorType.TruecolorWithAlpha);
im.save(exportPath, saveOptions);
}