Aspose.Psd for .NET - Strange image manipulation on 'Save' and error opening a file

Hi,

There are 2 situations that I’d like to request your help with:

1. Transparency added on basic load/save

I have an image that was manipulated using Aspose.PSD and its background was automatically manipulated without doing anything on my end.

This is the effect automatically applied (original on the left)

image (2).jpg (190.9 KB)

I’m not sure if it’s clear, but some sort of transparency was automatically added by Aspose.
This is a sample code that causes this behavior:

public static void func(string filePath)
{
    using (Aspose.PSD.FileFormats.Psd.PsdImage image = (Aspose.PSD.FileFormats.Psd.PsdImage)Aspose.PSD.Image.Load(filePath))
    {
        image.Save();
    }
}

I’m not exactly sure what’s happening, since everything seems normal with this image.

A relevant note: this happened in a PSD file with multiple layers. In order to test this, I copied the affected layer into a new PSD file, ran the same code and got the same result.

I’ll gladly share the file with Aspose’s team via Direct Message.

2. This compression method is not supported: ZipWithoutPrediction

I’m getting this error when trying to open a specific file.
This file has been previously manipulated via Aspose.PSD, but I’m not exactly sure what caused this problem.

My question is: is there any chance that Aspose is able to correctly open this file? And if not, could you please clarify what the problem is, so that I can figure out how to prevent this from happening in the first place?

I’ll also be able to share this file via Direct Message.

Thanks in advance!

@Pushbutton

  1. Could you please provide source file via direct message to me. Also, you can attach the file to this topic, it will be only accessible by Aspose Team.
  2. What version of Aspose.PSD do you use? We fixed the similar bug in Aspose.PSD 21.8: Aspose.PSD for .NET 21.8 - Release Notes|Documentation Anyway, could you please share source file via direct message or forum attachments.

Hi DmitriySorokin,

Thank you for the quick reply!

I’m currently using Aspose.PSD for .NET 21.12.0.

I’ll share both files via Direct Message in a moment.

Thanks!

@Pushbutton I make an investigation of reported issues. I can confirm them both. Were created the following bugs:

  1. PSDNET-1071: Aspose.PSD can’t open PSD (RGB/16bit) with ZipWithoutPrediction compression
  2. PSDNET-1072: Incorrect transparency on saving of PSD file (RGB/16bit) on export to 8bit

All these issues are related to 16 bit processing. The planned release where it will be fixed is 22.2 or 22.3.

At this moment I can suggest to you the following

  1. Resave “Unprocessable.psd” in any PSD Editor and then try to open it with Aspose.PSD again. It helped me. It looks like different editors save it differently and Aspose.PSD doesn’t cover all cases.
  2. Convert files from 16bit to 8bit quality if it’s not critical for you. It will lead to the quality loss.

Hi,

Thank you for your reply!

I also appreciate your suggestions, but as I unfortunately cannot follow them, I’ll wait for the fixes.

Hi again,

I’m checking in again about these bugs.
I noticed that the version 22.3 has been pushed, but these bugs aren’t in the release notes.

Could you please let me know if there’s an estimate of when these will be resolved?

Thank you!

@Pushbutton these issues are planned on 21.4, but there are risks that they will be postponed to 21.5

Hello,

I’m checking in again about these bugs.
Currently, in the version 22.6, these problems still persist.

Is there an estimate you can provide for these?

Thanks in advance

@Pushbutton at this moment only PSDNET-1072 “Incorrect transparency on saving of PSD file (RGB/16bit) on export to 8bit” is fixed. We tried to quickly fix PSDNET-1071, but found new blocking issues. We are working on issue with the incorrect compressing. After the fix of this logic your request will be given the highest priority.

@DmitriySorokin Thank you for the feedback!

Hi,

I’m checking in about the status of these tickets (PSDNET-1071 and PSDNET-2072).

Do you have any more details about when these fixes should be available?

Thanks!

@Pushbutton both task 1071 and 1072 are on code review. So, it’s possible that they will be in the nearest release.

Hi again,

I updated Aspose to the latest version:

  • Aspose.Imaging to 22.8.0
  • Aspose.PSD to 22.9.0

Unfortunately, the issue seems to persist:

  • Transparency is still lost
  • The generated file size is still shrunk by about the same amount - from 152MB to 3.66MB (I’m not sure if that’s relevant)

I’m still using the same file I provided - please let me know if you need me to send it to you again.

Is there something I may be missing? I’m still using the same code I mentioned earlier (‘Aspose.PSD.Image.Load’ followed by ‘image.Save()’)

Thank you

@Pushbutton Could you please clarify, did you try the code sample from the release notes? Aspose.PSD for .NET 22.9 - Release Notes|Documentation

string inputPsdFile    = "8bitWithTransparency.psd";
string outputPsdFile   = "16bitWithTransparency.psd";
string outputImageFile = "OutputWithTransparency.png";

using (var img = Image.Load(inputPsdFile))
{
    // 16 bit save options
    PsdOptions p16 = new PsdOptions() { ChannelBitsCount = 16, ColorMode = ColorModes.Rgb };

    img.Save(outputPsdFile, p16);
}
using (var img = Image.Load(outputPsdFile))
{
    // Save picture with 16 bit colors
    img.Save(outputImageFile, new PngOptions() { ColorType = Aspose.PSD.FileFormats.Png.PngColorType.TruecolorWithAlpha });
}

I checked this code sample and can confirm that in 21.8 it worked incorrect, after the saving of 8bit psd to 16 bit was missed transparency, but in Aspose.PSD 21.9 it works fine.

I have additional questions:

  1. Did you clean Solution after the updating of Aspose.PSD to 21.9?
  2. Do you use Aspose.PSD, but not Aspose.Imaging for this conversion?
  3. If it still doesn’t work correct, could you please send me full project with the input files and the result you are expecting.

Hi,

Sorry, I thought that just saving the file would now keep its colors, with no need to set the ‘options’ property.

I tried both of the code samples above:

  • outputPsdFile - the generated file still has transparency, when the original one doesn’t
  • outputImageFile - this file doesn’t have transparency, but I’m now losing a lot of information (since it becomes a PNG), such as layers

I’m not exactly sure what the problem is, as I have no deep knowledge of how image formats work, but is it possible for me to get a PSD fully similar to the original one?

Also, it seems that the problem are the bits per pixel - is there any way I can manipulate that, in order to get a similar result?

Finally, this problem appeared in this specific file, but the goal is to apply the algorithm to many different files - is there any way I can detect which files will have this problem just by looking at its properties?
I do not want to possibly ‘damage’ the other PSD files (which work fine), just because there’s a specific file where the ‘image.Save()’ method doesn’t work as expected.

Thanks in advance!

@Pushbutton could you please provide the some simple project with the source file and the expected result. Aspose.PSD can save any file in its previous color mode / bitdepth, but you should use save options this way: var options = new PsdOptions(sourcePsdImage);

If you provide the full code sample, we can help you to resolve issues.

I’ll send you a link where you can download a simple project (.NET Core 3.1, using the latest Aspose versions).
When you run this project, in the debug/release folder, you’ll see the created files, using different methods.

I ran a test, took a screenshot of how they look on Photoshop, and here are the results:
Output Comparison on Photoshop.jpg (399.4 KB)

Please ignore the watermark, as I didn’t add the license to the sample project.

As you can see, Method 1 and 2 add a visible change to the image (chess background from Photoshop is visible, if you zoom in) - this was also the same behavior on previous versions of Aspose.PSD (22.6.0, for example).

Note that method 1 uses the save options you’ve mentioned, however I was actually using the ‘save’ method without that parameter, which provided the same results (chess background).

This image is also in the project’s folder I’ll send via DM.

There’s another error I’m getting on 22.9 (I noticed earlier but I wasn’t sure if it was a problem on my end):
The generated files throw an error on Photoshop:

Problems were encountered readyng layers
"Background"
"BG"
because of a program error.

Thank you!

Hi, as requested, here’s the link to the sample project:
https://drive.google.com/drive/folders/1wOr3mL_RSc6vGW_1jp57W5MNJ_1S_pWQ?usp=sharing

Thank you

@Pushbutton thank you. I can confirm the bug. In the 1071 and 1072 were fixed issues with opening and conversion of 8bit to 16bit, but in the provided test project we have the opposite situation.

The publishing of the hot-fix for the Aspose.PSD 22.9 is planned for the next week, if it will be possible, the fix of your case will be added, otherwise, please follow the PSDNET-1281. Incorrect transparency on saving of 16 bit image to 16 or 8 bit image.

The issues you have found earlier (filed as PSDNET-1072) have been fixed in this update. This message was posted using Bugs notification tool by Yaroslav.Lisovskyi