Exception whenever saving PSD files > 200 MB AND large dimensions: The starting position is out of stream bounds

Hello, we’ve detected a problem where whenever we try to save any PSD greater than 200MB in size AND of a certain dimension or larger (15600px x 10800px @ 300dpi or larger) , it throws the following exception:

Message=“The starting position is out of stream bounds. (Parameter ‘position’)”

We are using version 24.1.0 of Aspose.PSD (.net version).

Even a simple loading and saving of a PSD file that’s 200MB or larger AND 15600px x 10800px @ 300dpi or larger will cause the problem with the following code which all it does is load the file and save it (no manipulation of layers)

    private MemoryStream SimpleExample()
    {
        PsdLoadOptions loadOptions = new PsdLoadOptions()
        {
            LoadEffectsResource = true,
            UseDiskForLoadEffectsResource = true
        };


        using (var im = (PsdImage) Aspose.PSD.Image.Load("c:\\temp\\bigfile.psd", loadOptions))
        {

            try
            {

                MemoryStream saveAsStream = new MemoryStream();
                im.Save(saveAsStream);   //Exception happens here

                return saveAsStream;
            }
            catch (Exception e)
            {
                return null;
            }
        }
    }

This problem occurs on every file with that size AND dimension or greater however what is interesting is that if you have a file that’s 100MB AND 15600px x 10800px, it will save fine without throwing an exception.

To eliminate the possibility that there’s something wrong with our PSD files, we created a brand new simple PSD file from scratch (referenced as bigfile.psd) in the code that’s 15600px x 10800px @ 300dpi which has only 1 layer that is filled with the bucket tool with the color #414141. The result of this is a file that is greater than 200MBs and 15600px x 10800px @ 300dpi and it will throw the aforementioned exception. If you delete half of the layer (that you filled with the Color #414141), the file size will drop to a little over 100MBs instead of 200MBs, and the save operation will work fine without throwing an exception so again, it’s a problem that’s a combination of the file size AND the dimension being greater than a certain threshold together (we have files that are smaller in dimensions that are over 200MBs in size that all work fine for instance).

Here’s a link to download bigfile.psd: bigfile.psd

We would greatly appreciate your help as this is a showstopper bug for us and will be happy to provide any additional information to help you reproduce the problem. Thanks!

@abroo
Thank you for the high quality bug report. I can confirm this issue.
We have opened the following new ticket(s) in our internal issue tracking system with the high priority and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PSDNET-1957

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi @Dmitriy.Sorokin , thanks for the response and for creating a high priority ticket for this. Would you happen to have a rough estimate of when you think this bug will get fixed and in what release? The only reason I ask is that this bug is blocking us from going to production so I just want to give our team a rough timeline of how long it will be delayed by. Thanks again for your help!

@abroo Aspose.PSD team starts this ticket in this month, depending on the complexity and load of the team this will be fixed in 24.3 or 24.4

Hello again @Dmitriy.Sorokin. Would you know if there’s any kind of temporary workaround for this while PSDNET-1957 is getting fixed?

@abroo unfortunately only one option is to use “ReadOnlyMode”, but it’s significantly limits the cases of using.

        PsdLoadOptions loadOptions = new PsdLoadOptions()
        {
            LoadEffectsResource = true,
            UseDiskForLoadEffectsResource = true,
            ReadOnlyMode = true
        };

This task has “High” priority. We will try to deliver its fix in 24.4.

Hi @Dmitriy.Sorokin , I just updated Aspose.PSD to 24.4.0 and it looks like the issue is still there. Did this not make it to 24.4?

The issue is fixed and now in the code review status. Unfortunately we didn’t have time to test and add this fix to 24.4, so it should appear in 24.5