diff --git a/AobaCore/AobaCore.csproj b/AobaCore/AobaCore.csproj
index 2efba3d..4b12dba 100644
--- a/AobaCore/AobaCore.csproj
+++ b/AobaCore/AobaCore.csproj
@@ -8,9 +8,7 @@
-
-
diff --git a/AobaCore/Services/ThumbnailService.cs b/AobaCore/Services/ThumbnailService.cs
index 149f602..7216744 100644
--- a/AobaCore/Services/ThumbnailService.cs
+++ b/AobaCore/Services/ThumbnailService.cs
@@ -3,8 +3,6 @@
using FFMpegCore;
using FFMpegCore.Pipes;
-using HeyRed.ImageSharp.Heif.Formats.Avif;
-using HeyRed.ImageSharp.Heif.Formats.Heif;
using MaybeError.Errors;
@@ -102,26 +100,22 @@ public class ThumbnailService(IMongoDatabase db, AobaService aobaService)
};
}
- private static Image LoadImageAsync(Stream stream, string ext)
+ private static Maybe LoadImageAsync(Stream stream, string ext)
{
if (ext is ".heif" or ".avif")
{
- var decoderOptions = new DecoderOptions()
- {
- Configuration = new Configuration(
- new AvifConfigurationModule(),
- new HeifConfigurationModule())
- };
- return Image.Load(decoderOptions, stream);
+ return new Error("Unsupported image type");
}
else
return Image.Load(stream);
}
- public static async Task GenerateImageThumbnailAsync(Stream stream, ThumbnailSize size, string ext, CancellationToken cancellationToken = default)
+ public static async Task> GenerateImageThumbnailAsync(Stream stream, ThumbnailSize size, string ext, CancellationToken cancellationToken = default)
{
var img = LoadImageAsync(stream, ext);
- img.Mutate(o =>
+ if (img.HasError)
+ return img.Error;
+ img.Value.Mutate(o =>
{
var size =
o.Resize(new ResizeOptions
@@ -132,7 +126,7 @@ public class ThumbnailService(IMongoDatabase db, AobaService aobaService)
});
});
var result = new MemoryStream();
- await img.SaveAsWebpAsync(result, cancellationToken);
+ await img.Value.SaveAsWebpAsync(result, cancellationToken);
result.Position = 0;
return result;
}
diff --git a/AobaServer/AobaServer.csproj b/AobaServer/AobaServer.csproj
index e742538..2cc0d77 100644
--- a/AobaServer/AobaServer.csproj
+++ b/AobaServer/AobaServer.csproj
@@ -24,7 +24,7 @@
-
+