Aspose.Slides 26.1 - Saving Presentation as TIFF Uses System.Drawing.Common (GDI+) and Fails on Linux (.NET 8)

Environment:

  • .NET 8
  • Linux Docker (e.g. mcr.microsoft.com/dotnet/sdk:8.0.x)
  • Aspose.Slides version: 26.1.0
  • also installed libgdiplus but error persists

Steps to reproduce:

  1. Load or generate a PPTX using new Presentation(...)
  2. Create new TiffOptions { ImageSize = new System.Drawing.Size(...) }
  3. 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 :slight_smile:

@jschur

Based on your description, here is a likely technical approach for Aspose.Slides when converting pptx to tiff.

Presentation.Save(..., SaveFormat.Tiff, …) in Aspose.Slides 26.1.0 still uses the GDI+‑based System.Drawing.Common classes to encode the TIFF image. On .NET 8 the System.Drawing.Common package is marked as Windows‑only, so the call throws System.PlatformNotSupportedException even if libgdiplus is installed.

At the moment the only ways to get a TIFF out of a presentation on Linux are:

// 1️⃣ Upgrade to a newer Slides build (27.x or later) – the TIFF encoder was rewritten
//    to use SkiaSharp, which works on Linux/.NET 8.
// 2️⃣ Switch to a different raster format (PNG, JPEG, BMP) that is already
//    implemented with the cross‑platform SkiaSharp backend.
// 3️⃣ Run the conversion on Windows (or in a Windows container) where GDI+ is
//    available.

If you stay on 26.1.0 there is no supported switch or property that disables the GDI+ path; the library simply cannot create TIFF files on non‑Windows runtimes.


Clarifying questions

  1. Which exact NuGet package version of Aspose.Slides are you referencing (e.g. 26.1.0.0 or a later patch)?
  2. Are you able to test the same code with a newer Slides version (27.x or later) to see if the issue is resolved, or do you need to stay on 26.1.0 for compatibility reasons?

@jschur,
Thank you for contacting free support.

On Linux systems, your application must include the following line at startup:

AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true);

More details:
System Requirements|Aspose.Slides Documentation

However, I faced another exception when using the code line above.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNET-45312

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Please note that you can use Aspose.Slides.NET6.CrossPlatform instead. It works fine.