Exif Helper
This commit is contained in:
49
Helpers/Exif/HelperExif.cs
Normal file
49
Helpers/Exif/HelperExif.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using File_Folder_Helper.Models.Exif;
|
||||
using File_Folder_Helper.Models.Face;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace File_Folder_Helper.Helpers.Exif;
|
||||
|
||||
internal static class HelperExif
|
||||
{
|
||||
|
||||
private static ReadOnlyCollection<FaceFile> GetCollection(ExifDirectoryBase[]? exifDirectoryBases)
|
||||
{
|
||||
List<FaceFile> results = [];
|
||||
if (exifDirectoryBases is not null)
|
||||
{
|
||||
string? json;
|
||||
FaceFile[]? collection;
|
||||
foreach (ExifDirectoryBase exifDirectoryBase in exifDirectoryBases)
|
||||
{
|
||||
json = exifDirectoryBase.Artist;
|
||||
if (string.IsNullOrEmpty(json))
|
||||
continue;
|
||||
collection = JsonSerializer.Deserialize(json, FaceFileCollectionGenerationContext.Default.FaceFileArray);
|
||||
if (collection is null)
|
||||
continue;
|
||||
results.AddRange(collection);
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
|
||||
internal static void DragAndDrop(ILogger<Worker> logger, string argZero)
|
||||
{
|
||||
FileInfo fileInfo = new(argZero);
|
||||
logger.LogInformation("<{argZero}> exists", argZero);
|
||||
ExifDirectory exifDirectory = Exif.GetExifDirectory(fileInfo);
|
||||
ReadOnlyCollection<FaceFile> collection = GetCollection(exifDirectory.ExifBaseDirectories);
|
||||
logger.LogInformation("<{collection}> value", collection.Count);
|
||||
foreach (FaceFile faceFile in collection)
|
||||
{
|
||||
if (faceFile.MappingFromPerson is null)
|
||||
logger.LogInformation("<{Confidence}> value", faceFile.Location?.Confidence);
|
||||
else
|
||||
logger.LogInformation("<{DisplayDirectoryName}> value", faceFile.MappingFromPerson.DisplayDirectoryName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user