Hello.
I’m using Aspose.PSD for .NET on a Linux environment to dynamically create a PSD file which includes images and I’m getting the following exception:
System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception. —> System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See Breaking change: System.Drawing.Common only supported on Windows - .NET | Microsoft Learn for more information. at System.Drawing.LibraryResolver.EnsureRegistered() at System.Drawing.SafeNativeMethods.Gdip.PlatformInitialize() at System.Drawing.SafeNativeMethods.Gdip…cctor() — End of inner exception stack trace — at System.Drawing.SafeNativeMethods.Gdip.GdipCreateRegion(IntPtr& region) at System.Drawing.Region…ctor() at e…ctor() at
Aspose.PSD.Graphics…ctor(Image sourceImage)
Looks like Aspose.PSD for .NET is internally using System.Drawing.Common which is not supported on Linux environments.
How can I make it work on Linux without having the System.Drawing.Common issue?
Thank you.
@diego.ledesma.ethofy
The exception you are encountering, System.PlatformNotSupportedException
, indicates that the System.Drawing.Common
library is not supported on non-Windows platforms, such as Linux. This is a known limitation as Microsoft has restricted the use of System.Drawing.Common
to Windows environments.
To work around this issue while using Aspose.PSD for .NET on Linux, you can consider the following options:
-
Use Aspose.Drawing: Instead of relying on System.Drawing.Common
, you can utilize the Aspose.Drawing library, which is designed to work across different platforms, including Linux. This library provides similar functionality for graphics operations without the platform restrictions.
-
Switch to a Windows Environment: If feasible, you could run your application in a Windows environment where System.Drawing.Common
is fully supported. This would eliminate the compatibility issues you are facing.
-
Docker with Windows Containers: If you need to run your application in a containerized environment, consider using Windows containers that support System.Drawing.Common
. This allows you to maintain a Linux-like deployment while still using Windows-specific libraries.
-
Alternative Libraries: Explore other cross-platform libraries for image processing that do not rely on System.Drawing.Common
. Libraries such as SkiaSharp or ImageSharp can be good alternatives for handling image manipulations in a cross-platform manner.
By implementing one of these solutions, you should be able to avoid the System.Drawing.Common
issue and successfully create PSD files in your Linux environment.
For more information on Aspose.PSD and its capabilities, you can refer to the Aspose.PSD for .NET API Reference.
If you have further questions or need assistance with specific code examples, feel free to ask!
Switching to Windows environment is unfortunately not an option.
Nowhere in the site is mentioned that the Aspose.PSD for .NET library is not Linux compatible. This should be clearly stated.
My understading is that Aspose.Drawing requires a separate license. Is that correct?
It doesn’t make sense that I need to buy two separate licenses for one library to perform correctly.
@diego.ledesma.ethofy could you please try Aspose.PSD for .NET , for .NET 7, .NET 8 or .NET 9. In these versions the Aspose.Drawing is used. If the issue reproduces, please describe your environment in details. Thank you.
@diego.ledesma.ethofy for using Aspose.PSD for .NET with Aspose.Drawing you don’t need the Aspose.Drawing License. Aspose.PSD Free Apps work on the Linux Environment, and Aspose.PSD works fine on MacOs. Please provide additional information about error, if Aspose.Drawing asks for the License.
Thanks for your response @Dmitriy.Sorokin.
Unfortunately we cannot update from .NET 6 at the moment since newer versions of .NET include breaking changes across many areas of our system.
We did try including Aspose.Drawing to our project, with the expectation that Aspose.PSD would reference it instead of System.Drawing but we are still getting the same stacktrace as mentioned above.
For Apose.Drawing we are currently using the free trail, which should have started a couple days ago.
Is there a way to make Aspose.PSD to work on .NET 6 on Linux using Aspose.Drawing as a standalone library?
What do we need to do to accomplish this?
Thank you.
@diego.ledesma.ethofy please check this Microsoft Article.
It possible to make System.Drawing work on Linux:
{
"configProperties": {
"System.Drawing.EnableUnixSupport": true
}
}
We considered release of Aspose.PSD with Aspose.Drawing for .NET 6, but it’s a first time when it we was asked about it.
Please check EnableLinuxSupport fix. If the issue will not be fixed, please write back to this forum topic.