Environment:
- .NET 8
- Linux Docker (e.g.
mcr.microsoft.com/dotnet/sdk:8.0.x) - Aspose.Slides version: 26.1.0
- also installed
libgdiplusbut error persists
Steps to reproduce:
- Load or generate a PPTX using
new Presentation(...) - Create
new TiffOptions { ImageSize = new System.Drawing.Size(...) } - Call
pres.Save(stream, SaveFormat.Tiff, options)
Actual result:
System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms
Stacktrace includes System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders().
Expected result:
Saving PPTX as TIFF should work on Linux (no dependency on System.Drawing.Common), or Aspose should provide a cross-platform alternative.
Test
using System.IO;
using Aspose.Slides;
using Aspose.Slides.Export;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SaveFormat = Aspose.Slides.Export.SaveFormat;
[TestClass]
public class AsposeTests
{
[TestMethod]
public void SaveGeneratedPptxAsTiff_throws_SystemDrawing_on_Linux()
{
// Arrange: generate a minimal PPTX in memory
using var pres = new Presentation();
pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 200, 50);
#pragma warning disable CS0618
var slideSize = pres.SlideSize.Size;
#pragma warning restore CS0618
var options = new TiffOptions
{
ImageSize = new System.Drawing.Size((int)slideSize.Width, (int)slideSize.Height)
};
// Act: Save to TIFF
using var outStream = new MemoryStream();
pres.Save(outStream, SaveFormat.Tiff, options);
Assert.IsTrue(outStream.Length > 0);
}
}
Docker-Log
Failed SaveGeneratedPptxAsTiff_throws_SystemDrawing_on_Linux [188 ms]
Error Message:
Test method AsposeTests.SaveGeneratedPptxAsTiff_throws_SystemDrawing_on_Linux threw exception:
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See https://aka.ms/systemdrawingnonwindows for more information.
Stack Trace:
at System.Drawing.SafeNativeMethods.Gdip.<>c.<.cctor>b__2_0(String _, Assembly _, Nullable`1 _)
at System.Runtime.InteropServices.NativeLibrary.LoadLibraryCallbackStub(String libraryName, Assembly assembly, Boolean hasDllImportSearchPathFlags, UInt32 dllImportSearchPathFlags)
at System.Drawing.SafeNativeMethods.Gdip.<GdiplusStartup>g____PInvoke|32_0(IntPtr* __token_native, StartupInputEx* __input_native, StartupOutput* __output_native)
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInputEx& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip..cctor()
--- End of inner exception stack trace ---
at System.Drawing.SafeNativeMethods.Gdip.GdipGetImageEncodersSize(Int32& numEncoders, Int32& size)
at System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()
at .(Presentation , Stream , Int32[] , TiffOptions , InterruptionToken )
at .(Presentation , Stream , TiffOptions , InterruptionToken )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at AsposeTests.SaveGeneratedPptxAsTiff_throws_SystemDrawing_on_Linux()
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
My docker file:
# syntax=docker/dockerfile:1.7
FROM mcr.microsoft.com/dotnet/sdk:8.0.204 AS build
WORKDIR /src
# we need libSkiaSharp in linux container
RUN apt-get update && apt-get install -y \
curl ca-certificates \
libfontconfig1 \
libfreetype6 \
libpng16-16 \
libjpeg62-turbo \
libgif7 \
libwebp7 \
libgdiplus \
&& rm -rf /var/lib/apt/lists/*
RUN curl -LsS https://aka.ms/install-artifacts-credprovider.sh | bash
ENV NUGET_CREDENTIALPROVIDERS_PATH=/root/.nuget/plugins
COPY *.sln ./
COPY NuGet.Config ./
COPY global.json ./
COPY Directory.Build.props ./
COPY Directory.Build.targets ./
COPY *.ruleset ./
COPY *.snk ./
COPY Aspose.Total.2027.lic ./Aspose.Total.2027.lic
COPY Capmatix.MergerCore/ ./Capmatix.MergerCore/
COPY DocGenCore.RegressionTest/ ./DocGenCore.RegressionTest/
COPY TestHelper/ ./TestHelper/
COPY Capmatix.MergerCore.Contracts/ ./Capmatix.MergerCore.Contracts/
COPY Capmatix.MergerCore.Common/ ./Capmatix.MergerCore.Common/
RUN dotnet restore --configfile /src/NuGet.Config
RUN dotnet build -c Release -f net8.0 --no-restore
RUN dotnet test -c Release -f net8.0 --no-build --logger "trx;LogFileName=test_results.trx"
I hope you can reproduce the test and fix it soon ![]()