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.
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.
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.
@Pushbutton I make an investigation of reported issues. I can confirm them both. Were created the following bugs:
PSDNET-1071: Aspose.PSD can’t open PSD (RGB/16bit) with ZipWithoutPrediction compression
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
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.
Convert files from 16bit to 8bit quality if it’s not critical for you. It will lead to the quality loss.
@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.
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:
Did you clean Solution after the updating of Aspose.PSD to 21.9?
Do you use Aspose.PSD, but not Aspose.Imaging for this conversion?
If it still doesn’t work correct, could you please send me full project with the input files and the result you are expecting.
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.
@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.
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.
@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