Free Support Forum - aspose.com

Issue Saving Image as Raster

Hello,

I’ve just updated my version of Aspose.PSD and am now getting the following error when trying to save an edited PSD to raster formats:

Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.

@LiamDowenGould,

I have observed the issue shared by you and request you to please try using Aspose.PSD for .NET 20.2 on your end. In case there is still an issue then please share the working sample code along with source file and issue screenshot. We will be able to investigate the issue further on our end on provision of requested information.

                PngOptions pngOptions = new PngOptions();
                pngOptions.ColorType = PngColorType.GrayscaleWithAlpha;
                psdImage.Save(savePath, pngOptions);

This also occurs on 20.2
This only happens after updating the text layers, if I comment out the code that does that it will save.
textLayer.UpdateText("Liam", colour);

Aspose.zip (190.7 KB)

@LiamDowenGould,

I have observed the PSD and part of code sample for using PNG options and saving PSD as PNG. I request you to please provide a working sample example that you are using on your end to reproduce the issue. We will use that on our end to reproduce the same and log the issue if it gets reproduced.

I’m unable to provide the full working code as you would have to have full access to our data model, but this is a simplified version what is happening.

using (PsdImage psdImage = (PsdImage)Aspose.PSD.Image.Load("/path/to/file"))
{
	foreach (var layer in psdImage.Layers)
	{
		if (layer is TextLayer)
		{
			TextLayer textLayer = layer as TextLayer;	
			textLayer.UpdateText("Test", Aspose.PSD.Color.Black);
		}
		
	}

	PngOptions pngOptions = new PngOptions();
	pngOptions.ColorType = PngColorType.GrayscaleWithAlpha;
	psdImage.Save(savePath, pngOptions);
}

It’s worth noting, that this doesn’t occur when I comment out the line to update the text.

@LiamDowenGould,

I have observed the issue shared. An issue with ID PSDNET-556 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.