Hosting Aspose.Imaging aspnet.core on Alpine Linux

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.

@mcrose, you need to install libgdiplus from mono, as well as a minimum set of fonts.
For Ubuntu dockerfile looks like this:

RUN apt-get update \
    && apt-get install -y \
        apt-transport-https \
        dirmngr \
        gnupg \
        ca-certificates

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
    && echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" >> /etc/apt/sources.list.d/mono-official-stable.list

    
RUN apt-get update && apt-get install -y libgdiplus libc6-dev libx11-dev libfontconfig1 xfonts-utils


RUN DEBIAN_FRONTEND=noninteractive apt-get install -y ttf-mscorefonts-installer

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)

DOCKERFILE

FROM:mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic

RUN apt-get update && apt-get install -y --no-install-recommends gss-ntlmssp

ENV DEBIAN_FRONTEND=noninteractive
ENV ACCEPT_EULA=Y

RUN apt-get update
&& apt-get install -y --allow-unauthenticated
libc6-dev
libgdiplus
libx11-dev
ttf-mscorefonts-installer
&& rm -rf /var/lib/apt/lists/*

Aspose.Imaging

Hosting Aspose.Imaging aspnet.core on Alpine Linux - #2 by stanislav.popov

RUN apt-get update && apt-get install -y libgdiplus libc6-dev libx11-dev libfontconfig1 xfonts-utils
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y ttf-mscorefonts-installer

#Apose.Words

How to Run Aspose.Words in Docker|Aspose.Words for .NET

RUN apt-get update && apt-get install -y libfontconfig1
RUN apt-get -y install libharfbuzz-icu0

RUN apt-get update && apt-get install -y libgdiplus libc6-dev libx11-dev libfontconfig1 xfonts-utils
RUN DEBIAN_FRONTEND=noninteractive && -get install -y ttf-mscorefonts-installer

@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.

Awesome.
Wrong board, I know - but do you know if Aspose.PDF will be migrating to Aspose.Drawing soon as well?

@mcrose, unfortunately we do not know exact plans of aspose.pdf, but you can ask them in related topic.