[backend/drive] Switch to ImageSharp fork supporting IsAnimated metadata property

This fixes compatibility with all animated webp/png images.
This commit is contained in:
Laura Hausmann 2024-07-17 18:02:07 +02:00
parent 12cbc40f99
commit 100d74175a
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
3 changed files with 5 additions and 2 deletions

View file

@ -4,6 +4,7 @@ using Iceshrimp.Backend.Core.Database.Tables;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using SixLabors.ImageSharp; using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Formats.Webp;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
@ -93,7 +94,7 @@ public class ImageProcessor
// Correct mime type // Correct mime type
if (request.MimeType == "image" && ident.Metadata.DecodedImageFormat?.DefaultMimeType != null) if (request.MimeType == "image" && ident.Metadata.DecodedImageFormat?.DefaultMimeType != null)
request.MimeType = ident.Metadata.DecodedImageFormat.DefaultMimeType; 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"; request.MimeType = "image/apng";
if (_config.CurrentValue.MediaProcessing.ImageProcessor == Enums.ImageProcessor.None) if (_config.CurrentValue.MediaProcessing.ImageProcessor == Enums.ImageProcessor.None)
@ -103,7 +104,7 @@ public class ImageProcessor
} }
// Don't generate thumb/webp for animated images // 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; genThumb = false;
genWebp = false; genWebp = false;

View file

@ -37,6 +37,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="8.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.3" /> <PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.3" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.5-iceshrimp" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="System.IO.Hashing" Version="8.0.0" /> <PackageReference Include="System.IO.Hashing" Version="8.0.0" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" /> <PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />

View file

@ -14,6 +14,7 @@
<package pattern="Iceshrimp.*" /> <package pattern="Iceshrimp.*" />
<package pattern="dotNetRdf.Core" /> <package pattern="dotNetRdf.Core" />
<package pattern="NetVips.Native" /> <package pattern="NetVips.Native" />
<package pattern="SixLabors.ImageSharp" />
</packageSource> </packageSource>
</packageSourceMapping> </packageSourceMapping>
</configuration> </configuration>