From a76ba90aad838f62a63b12d1e75a0cece7665015 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 16 Sep 2023 18:01:49 -0400 Subject: [PATCH] Add LocalImageFile.ImageSize --- .../Models/Database/LocalImageFile.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/StabilityMatrix.Core/Models/Database/LocalImageFile.cs b/StabilityMatrix.Core/Models/Database/LocalImageFile.cs index 3fea76a3..73639506 100644 --- a/StabilityMatrix.Core/Models/Database/LocalImageFile.cs +++ b/StabilityMatrix.Core/Models/Database/LocalImageFile.cs @@ -2,6 +2,7 @@ using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Models.FileInterfaces; using JsonSerializer = System.Text.Json.JsonSerializer; +using Size = System.Drawing.Size; namespace StabilityMatrix.Core.Models.Database; @@ -36,6 +37,11 @@ public class LocalImageFile /// public GenerationParameters? GenerationParameters { get; set; } + /// + /// Dimensions of the image + /// + public Size? ImageSize { get; set; } + /// /// File name of the relative path. /// @@ -101,6 +107,9 @@ public class LocalImageFile FileShare.Read ); using var reader = new BinaryReader(stream); + + var imageSize = ImageMetadata.GetImageSize(reader); + var metadata = ImageMetadata.ReadTextChunk(reader, "parameters-json"); GenerationParameters? genParams = null; @@ -121,7 +130,8 @@ public class LocalImageFile ImageType = imageType, CreatedAt = filePath.Info.CreationTimeUtc, LastModifiedAt = filePath.Info.LastWriteTimeUtc, - GenerationParameters = genParams + GenerationParameters = genParams, + ImageSize = imageSize }; }