We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Create Raster Mask


I need to create a PSD file which suppose to have multiple layers and each layer needs to have a raster mask.
For raster mask I need to set mask from svg or png file as its based path.

I tried below lines but getting this error:
Invalid layer mask parameter (ImageData). Mask data bytes length should be equal MaskRectangle.Width * MaskRectangle.Height properties.

 LayerMaskData layerMask = new LayerMaskDataFull();
 layerMask.MaskRectangle = new Rectangle(0, 0, dto.Width, dto.Height);
 layerMask.ImageData =  mask;

the mask is byte array which parsed from my png file.

Wondering if there is any sample exists.

Thank you


The some examples can be found here https://docs.aspose.com/psd/net/editing-raster-layer-masks-in-psd-file-via-api/

Could you please provide the full working code (with creation or opening the PSD Image).

Unfortunately, I couldn’t find similar example there.

I pushed my code into public repo.
Kindly have a look.


Also, I shared what I wish to achieve here for your reference.

@MoeMollaei I created a task: PSDNET-1364. Prepare an example of adding mask or/and improve the API to make it simpler

It will be investigated next week and then you will be texted or will be created a task about improvement of API