Are there apt-get commands that required to run Aspose.Imaging on an Alpine Linux Docker Image
I have a web service built on the Aspose family (Words, PDF, and Imaging) to convert a list of submitted documents PDF (versions 22.7 and 22.8)
This service works great on a Windows Server, however when hosted on a Linux Alpine Docker image Aspose.Imaging.Image.Load(inputStream) throws the exception, “Image loading failed.”
There are apt-get commands posted on this support site to update the Docker image with required libraries for Aspose.Words, and Aspose.PDF, but I haven’t found anything for Aspose.Imaging.
Thank you for the suggestion.
I tried it, and has not helped (DOCKERFILE below)
Any other suggestions?
The exception is thrown from
Aspose.Imaging.Image.Load(inputStream)
The exception and inner exceptions are logged
TifToPdfStream() inputStream.length=1272
TifToPdfStream() Exception.Message: Image loading failed.
InnerEx: Unable to read file. Exception: The type initializer for ‘Gdip’ threw an exception.
Stack =
at Aspose.Imaging.Image.Load(StreamContainer , LoadOptions )
at Aspose.Imaging.Image.Load(Stream stream, LoadOptions loadOptions)
at Aspose.Imaging.Image.Load(Stream stream)
@mcrose, I added a test project with a dockerfile, this project runs under Linux.
You can take the dockerfile from there and modify it to suit your needs. TestProject.zip (592.1 KB)
Follow up.
System.Drawing is disabled/unavailable by default in .NET 6.
But even if you’re only on .NET Core 3.1 this will affect you if you update your Microsoft Library nuget packages to version 6.
If you run into the problem described above you can roll-back your MS nuget packages to not use version 6.* or you can add the file runtimeconfig.template.json at the same level as your application .csproj with the content
{
“configProperties”: {
“System.Drawing.EnableUnixSupport”: true
}
}
@mcrose, restriction with System.Drawing we know, and already we support beta version of Aspose.Imaging that uses another graphics engine - Aspose.Drawing. You can use it. It is available at NuGet Gallery | Aspose.Imaging 22.10.0-beta Aspose.Drawing engine is supported for versions from NetStandard2.0 and higher for Aspose.Imaging.