diff --git a/AobaCore/AobaCore.csproj b/AobaCore/AobaCore.csproj
index 616d0cf..2efba3d 100644
--- a/AobaCore/AobaCore.csproj
+++ b/AobaCore/AobaCore.csproj
@@ -8,15 +8,17 @@
+
-
+
+
-
-
+
+
-
+
diff --git a/AobaCore/Services/ThumbnailService.cs b/AobaCore/Services/ThumbnailService.cs
index f28201c..149f602 100644
--- a/AobaCore/Services/ThumbnailService.cs
+++ b/AobaCore/Services/ThumbnailService.cs
@@ -3,6 +3,9 @@
using FFMpegCore;
using FFMpegCore.Pipes;
+using HeyRed.ImageSharp.Heif.Formats.Avif;
+using HeyRed.ImageSharp.Heif.Formats.Heif;
+
using MaybeError.Errors;
using MongoDB.Bson;
@@ -10,6 +13,7 @@ using MongoDB.Driver;
using MongoDB.Driver.GridFS;
using SixLabors.ImageSharp;
+using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Processing;
using System;
@@ -91,16 +95,32 @@ public class ThumbnailService(IMongoDatabase db, AobaService aobaService)
{
return type switch
{
- MediaType.Image => await GenerateImageThumbnailAsync(stream, size, cancellationToken),
+ MediaType.Image => await GenerateImageThumbnailAsync(stream, size, ext, cancellationToken),
MediaType.Video => GenerateVideoThumbnail(stream, size, cancellationToken),
MediaType.Text or MediaType.Code => await GenerateDocumentThumbnailAsync(stream, size, cancellationToken),
_ => new Error($"No Thumbnail for {type}"),
};
}
- public static async Task GenerateImageThumbnailAsync(Stream stream, ThumbnailSize size, CancellationToken cancellationToken = default)
+ private static Image LoadImageAsync(Stream stream, string ext)
{
- var img = Image.Load(stream);
+ if (ext is ".heif" or ".avif")
+ {
+ var decoderOptions = new DecoderOptions()
+ {
+ Configuration = new Configuration(
+ new AvifConfigurationModule(),
+ new HeifConfigurationModule())
+ };
+ return Image.Load(decoderOptions, stream);
+ }
+ else
+ return Image.Load(stream);
+ }
+
+ public static async Task GenerateImageThumbnailAsync(Stream stream, ThumbnailSize size, string ext, CancellationToken cancellationToken = default)
+ {
+ var img = LoadImageAsync(stream, ext);
img.Mutate(o =>
{
var size =
@@ -141,7 +161,7 @@ public class ThumbnailService(IMongoDatabase db, AobaService aobaService)
output.Position = 0;
return output;
}
- catch(Exception ex)
+ catch (Exception ex)
{
return ex;
}
@@ -155,4 +175,4 @@ public class ThumbnailService(IMongoDatabase db, AobaService aobaService)
{
return new NotImplementedException();
}
-}
+}
\ No newline at end of file
diff --git a/AobaServer/AobaServer.csproj b/AobaServer/AobaServer.csproj
index 64b9f2a..e742538 100644
--- a/AobaServer/AobaServer.csproj
+++ b/AobaServer/AobaServer.csproj
@@ -16,7 +16,7 @@
all
-
+
diff --git a/AobaServer/Proto/Types.proto b/AobaServer/Proto/Types.proto
index 2df1884..4caeb13 100644
--- a/AobaServer/Proto/Types.proto
+++ b/AobaServer/Proto/Types.proto
@@ -103,11 +103,11 @@ message ShareXResponse {
message SearchQuery {
- optional string queryText = 1;
- repeated Filter filters = 2;
-}
-
-message Filter {
- string key = 1;
- repeated string values = 2;
+ optional string queryText = 1;
+ repeated Filter filters = 2;
+}
+
+message Filter {
+ string key = 1;
+ repeated string values = 2;
}
\ No newline at end of file