Browse Source

Add LocalImageFile.ImageSize

pull/165/head
Ionite 1 year ago
parent
commit
a76ba90aad
No known key found for this signature in database
  1. 12
      StabilityMatrix.Core/Models/Database/LocalImageFile.cs

12
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
/// </summary>
public GenerationParameters? GenerationParameters { get; set; }
/// <summary>
/// Dimensions of the image
/// </summary>
public Size? ImageSize { get; set; }
/// <summary>
/// File name of the relative path.
/// </summary>
@ -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
};
}

Loading…
Cancel
Save