From 100d74175aa933c4bb7ab090cc988aa56be068a9 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Wed, 17 Jul 2024 18:02:07 +0200 Subject: [PATCH] [backend/drive] Switch to ImageSharp fork supporting IsAnimated metadata property This fixes compatibility with all animated webp/png images. --- Iceshrimp.Backend/Core/Services/ImageProcessor.cs | 5 +++-- Iceshrimp.Backend/Iceshrimp.Backend.csproj | 1 + NuGet.Config | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Iceshrimp.Backend/Core/Services/ImageProcessor.cs b/Iceshrimp.Backend/Core/Services/ImageProcessor.cs index 657ce94d..d2758a26 100644 --- a/Iceshrimp.Backend/Core/Services/ImageProcessor.cs +++ b/Iceshrimp.Backend/Core/Services/ImageProcessor.cs @@ -4,6 +4,7 @@ using Iceshrimp.Backend.Core.Database.Tables; using Microsoft.Extensions.Options; using SixLabors.ImageSharp; using SixLabors.ImageSharp.Formats; +using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -93,7 +94,7 @@ public class ImageProcessor // Correct mime type if (request.MimeType == "image" && ident.Metadata.DecodedImageFormat?.DefaultMimeType != null) request.MimeType = ident.Metadata.DecodedImageFormat.DefaultMimeType; - if (ident.Metadata.TryGetPngMetadata(out var pngMetadata) && pngMetadata.AnimateRootFrame) + if (ident.Metadata.DecodedImageFormat is PngFormat && ident.IsAnimated) request.MimeType = "image/apng"; if (_config.CurrentValue.MediaProcessing.ImageProcessor == Enums.ImageProcessor.None) @@ -103,7 +104,7 @@ public class ImageProcessor } // Don't generate thumb/webp for animated images - if (ident.FrameMetadataCollection.Count != 0 || pngMetadata?.AnimateRootFrame == true) + if (ident.FrameMetadataCollection.Count != 0 || ident.IsAnimated) { genThumb = false; genWebp = false; diff --git a/Iceshrimp.Backend/Iceshrimp.Backend.csproj b/Iceshrimp.Backend/Iceshrimp.Backend.csproj index 0af24570..899ea7d2 100644 --- a/Iceshrimp.Backend/Iceshrimp.Backend.csproj +++ b/Iceshrimp.Backend/Iceshrimp.Backend.csproj @@ -37,6 +37,7 @@ + diff --git a/NuGet.Config b/NuGet.Config index ea2c0e72..b4b76892 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -14,6 +14,7 @@ +