diff --git a/Compare/appsettings.Development.json b/Compare/appsettings.Development.json index 0a88493..123adda 100644 --- a/Compare/appsettings.Development.json +++ b/Compare/appsettings.Development.json @@ -89,10 +89,34 @@ "PropertiesChangedForProperty": false, "RootDirectory": "C:/Tmp/Phares/Compare/Images-dd514b88", "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", + ".nef", + ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "PropertyContentCollectionFiles": [ "/Images-ec5a909 - Results/A) Property/2022-12-30/[()]/637869381676042455.json", @@ -104,20 +128,24 @@ "/Not-Copy-Copy - Delta/Blackberry - Results/A) Property/2022-12-30/[()]/637869745134124462.json" ], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ], "VerifyToSeason": [ ". 2000", diff --git a/Compare/appsettings.json b/Compare/appsettings.json index bddb6d5..0450337 100644 --- a/Compare/appsettings.json +++ b/Compare/appsettings.json @@ -90,12 +90,34 @@ "/zzz Phares Slides/Slides 2015-06-10/Magazine 01" ], "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", ".nef", ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "PropertyContentCollectionFiles": [ "/Images-ec5a909 - Results/A) Property/2022-12-30/[()]/637869381676042455.json", @@ -107,20 +129,24 @@ "/Not-Copy-Copy - Delta/Blackberry - Results/A) Property/2022-12-30/[()]/637869745134124462.json" ], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ], "VerifyToSeason": [ ". 2000", diff --git a/Container/Models/Stateless/Methods/Container.cs b/Container/Models/Stateless/Methods/Container.cs index 4151aa8..f73358c 100644 --- a/Container/Models/Stateless/Methods/Container.cs +++ b/Container/Models/Stateless/Methods/Container.cs @@ -133,9 +133,9 @@ internal abstract class Container ReadOnlyCollection filePairs; int maxDegreeOfParallelism = Environment.ProcessorCount; int filesCollectionDirectoryLength = filesCollectionDirectory.Length; + string aResultsFullGroupDirectory = dlibDotNet.GetResultsFullGroupDirectories(); ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = maxDegreeOfParallelism }; - (_, string bResultsFullGroupDirectory) = dlibDotNet.GetResultsFullGroupDirectories(); - string jsonGroupDirectory = Path.Combine(bResultsFullGroupDirectory, propertyConfiguration.ResultSingleton); + string jsonGroupDirectory = Path.Combine(aResultsFullGroupDirectory, propertyConfiguration.ResultSingleton); if (!Directory.Exists(jsonGroupDirectory)) _ = Directory.CreateDirectory(jsonGroupDirectory); filePairs = IFilePair.GetFilePairs(propertyConfiguration, directorySearchFilter, extension, jsonGroupDirectory, filePathsCollection); @@ -226,8 +226,8 @@ internal abstract class Container if (filePaths is not null && change is not null) RenameFile(filePair, filePair.FilePath, change.Value, filePaths); } + lastWriteTimeChanged = exifDirectory?.FilePath is not null ? exifDirectory.FilePath.LastWriteTicks != filePair.FilePath.LastWriteTicks : null; relativePath = Shared.Models.Stateless.Methods.IPath.GetRelativePath(filePair.FilePath.FullName, rootDirectoryLength, forceExtensionToLower: true); - lastWriteTimeChanged = exifDirectory?.FilePath is not null ? propertyConfiguration.PropertiesChangedForProperty || exifDirectory.FilePath.LastWriteTicks != filePair.FilePath.LastWriteTicks : null; if (filePair.Match is not null) sourceDirectoryFileHolder = IFileHolder.Get(filePair.Match); else if (!filePair.IsUnique) @@ -381,8 +381,8 @@ internal abstract class Container private static void AnyMoved(IDlibDotNet dlibDotNet, IPropertyConfiguration propertyConfiguration, string facesFileNameExtension, string facesHiddenFileNameExtension, string eDistanceContentDirectory, ReadOnlyCollection> filePathsCollection, ReadOnlyDictionary> idToFilePaths, string directorySearchFilter) { const string extension = ".json"; - (_, string bResultsFullGroupDirectory) = dlibDotNet.GetResultsFullGroupDirectories(); - string bMetaSingletonDirectory = Path.Combine(bResultsFullGroupDirectory, propertyConfiguration.ResultSingleton); + string aResultsFullGroupDirectory = dlibDotNet.GetResultsFullGroupDirectories(); + string bMetaSingletonDirectory = Path.Combine(aResultsFullGroupDirectory, propertyConfiguration.ResultSingleton); if (!Directory.Exists(bMetaSingletonDirectory)) _ = Directory.CreateDirectory(bMetaSingletonDirectory); _ = IFilePair.GetFilePairs(propertyConfiguration, directorySearchFilter, extension, bMetaSingletonDirectory, filePathsCollection); diff --git a/Copy-Distinct/appsettings.json b/Copy-Distinct/appsettings.json index c8ca0f8..18c1c9d 100644 --- a/Copy-Distinct/appsettings.json +++ b/Copy-Distinct/appsettings.json @@ -71,28 +71,54 @@ "ResultSingleton": "{}", "RootDirectory": "D:/Images", "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", ".nef", ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ] } } diff --git a/Date-Group/DateGroup.cs b/Date-Group/DateGroup.cs index b345ce8..dd03f08 100644 --- a/Date-Group/DateGroup.cs +++ b/Date-Group/DateGroup.cs @@ -46,7 +46,7 @@ public class DateGroup if (!_IsEnvironment.Development) throw new Exception("This program only allows development environments!"); long ticks = DateTime.Now.Ticks; - Metadata.Models.B_Metadata metadata = new(propertyConfiguration); + Metadata.Models.A_Metadata metadata = new(propertyConfiguration); string[] dbFiles = Directory.GetFiles(propertyConfiguration.RootDirectory, "*.db", SearchOption.AllDirectories); foreach (string dbFile in dbFiles) File.Delete(dbFile); diff --git a/Date-Group/appsettings.json b/Date-Group/appsettings.json index 4629be4..22cd744 100644 --- a/Date-Group/appsettings.json +++ b/Date-Group/appsettings.json @@ -70,29 +70,55 @@ "ResultSingleton": "{}", "RootDirectory": "C:/Tmp/phares/Pictures", "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", ".nef", ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "PropertyContentCollectionFiles": [], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ], "VerifyToSeason": [ ". 2000", diff --git a/Delete-By-Distinct/appsettings.json b/Delete-By-Distinct/appsettings.json index c0bf764..b469e0a 100644 --- a/Delete-By-Distinct/appsettings.json +++ b/Delete-By-Distinct/appsettings.json @@ -72,28 +72,54 @@ "ResultSingleton": "{}", "RootDirectory": "C:/Tmp/Phares/Compare/Images-dd514b88", "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", ".nef", ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ] } } diff --git a/Delete-By-Relative/appsettings.json b/Delete-By-Relative/appsettings.json index a9a0ba6..03e3334 100644 --- a/Delete-By-Relative/appsettings.json +++ b/Delete-By-Relative/appsettings.json @@ -67,28 +67,54 @@ "ResultSingleton": "{}", "RootDirectory": "C:/Tmp/Phares/Compare/Images-dd514b88", "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", ".nef", ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ] } } diff --git a/Distance/Models/_E_Distance.cs b/Distance/Models/_E_Distance.cs index 82233c1..33559a9 100644 --- a/Distance/Models/_E_Distance.cs +++ b/Distance/Models/_E_Distance.cs @@ -229,7 +229,7 @@ public partial class E_Distance : IDistance throw new NullReferenceException(nameof(locationContainer.ExifDirectory)); continue; } - json = Metadata.Models.Stateless.Methods.IMetadata.GetFaceEncoding(locationContainer.ExifDirectory); + json = Metadata.Models.Stateless.Methods.IMetadata.GetRawFaceEncoding(locationContainer.ExifDirectory); if (json is null) { if (_DistanceMoveUnableToMatch) @@ -338,7 +338,6 @@ public partial class E_Distance : IDistance public static ReadOnlyDictionary> GetMappedWithEncoding(ReadOnlyDictionary> mapped) { Dictionary> results = []; - string? json; LocationContainer? locationContainer; Shared.Models.FaceEncoding? faceEncoding; FaceRecognitionDotNet.FaceEncoding? encoding; @@ -348,8 +347,7 @@ public partial class E_Distance : IDistance keyValuePairs = []; foreach (KeyValuePair keyValue in keyValuePair.Value) { - json = Metadata.Models.Stateless.Methods.IMetadata.GetFaceEncoding(keyValue.Value.ExifDirectory); - faceEncoding = json is null ? null : JsonSerializer.Deserialize(json); + faceEncoding = Metadata.Models.Stateless.Methods.IMetadata.GetFaceEncoding(keyValue.Value.ExifDirectory); if (faceEncoding is null) continue; encoding = FaceRecognition.LoadFaceEncoding(faceEncoding.RawEncoding); @@ -364,7 +362,6 @@ public partial class E_Distance : IDistance public static List GetPreFilterLocationContainer(int maxDegreeOfParallelism, Configuration configuration, string focusDirectory, string focusModel, int? skipPersonWithMoreThen, long ticks, MapLogic mapLogic, long[] jLinkResolvedPersonKeys, ReadOnlyDictionary> mapped, List available) { List results = []; - string? json; string? model; bool? canReMap; bool? isFocusPerson; @@ -403,8 +400,7 @@ public partial class E_Distance : IDistance if (!locationContainer.FilePath.DirectoryFullPath.Contains(focusDirectory)) continue; } - json = Metadata.Models.Stateless.Methods.IMetadata.GetFaceEncoding(locationContainer.ExifDirectory); - faceEncoding = json is null ? null : JsonSerializer.Deserialize(json); + faceEncoding = Metadata.Models.Stateless.Methods.IMetadata.GetFaceEncoding(locationContainer.ExifDirectory); if (faceEncoding is null) continue; encoding = FaceRecognition.LoadFaceEncoding(faceEncoding.RawEncoding); @@ -678,16 +674,12 @@ public partial class E_Distance : IDistance ReadOnlyCollection IDistance.GetRelationContainers(IDistanceLimits distanceLimits, int faceDistancePermyriad, int locationContainerDistanceTake, float locationContainerDistanceTolerance, ReadOnlyCollection locationContainers) { ReadOnlyCollection result; - string? json; List records = []; Shared.Models.FaceEncoding? modelsFaceEncoding; FaceRecognitionDotNet.FaceEncoding faceRecognitionDotNetFaceEncoding; foreach (LocationContainer locationContainer in locationContainers) { - json = Metadata.Models.Stateless.Methods.IMetadata.GetFaceEncoding(locationContainer.ExifDirectory); - if (json is null) - continue; - modelsFaceEncoding = JsonSerializer.Deserialize(json); + modelsFaceEncoding = Metadata.Models.Stateless.Methods.IMetadata.GetFaceEncoding(locationContainer.ExifDirectory); if (modelsFaceEncoding is null) throw new NotSupportedException(); faceRecognitionDotNetFaceEncoding = FaceRecognition.LoadFaceEncoding(modelsFaceEncoding.RawEncoding); diff --git a/Duplicate-Search/appsettings.json b/Duplicate-Search/appsettings.json index e5b1778..72b04ac 100644 --- a/Duplicate-Search/appsettings.json +++ b/Duplicate-Search/appsettings.json @@ -68,28 +68,54 @@ "ResultSingleton": "{}", "RootDirectory": "C:/Tmp/Phares/Compare/Images-dd514b88", "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", ".nef", ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ] } } diff --git a/Face/Models/_D_Face.cs b/Face/Models/_D_Face.cs index 232e5cf..339fc5f 100644 --- a/Face/Models/_D_Face.cs +++ b/Face/Models/_D_Face.cs @@ -190,7 +190,7 @@ public class D_Face : IFaceD FileHolder fileHolder; string deterministicHashCodeKey; string fileName = mappingFromItem.FilePath.NameWithoutExtension; - string[] changesFrom = [nameof(A_Property), nameof(B_Metadata), nameof(C_Resize)]; + string[] changesFrom = [nameof(A_Metadata), nameof(C_Resize)]; List dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList(); CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, filePath); string directory = _ResultContentFileGroups[0][cei.Enum][cei.Index]; @@ -269,7 +269,7 @@ public class D_Face : IFaceD List? results; string? json; List locations; - string[] changesFrom = [nameof(A_Property), nameof(B_Metadata), nameof(C_Resize)]; + string[] changesFrom = [nameof(A_Metadata), nameof(C_Resize)]; List dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList(); string fileName = $"{mappingFromItem.FilePath.NameWithoutExtension}{mappingFromItem.FilePath.ExtensionLowered}.json"; CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, filePath); @@ -475,7 +475,7 @@ public class D_Face : IFaceD dFace.ReSaveFace(exifDirectory, filePath, face, mappedFile: false); continue; } - location = Shared.Models.Stateless.Methods.ILocation.GetLocation(face.Location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, source.Height, source.Width, collection.Count); + location = Shared.Models.Stateless.Methods.ILocation.GetLocation(face.Location, source.Height, source.Width, collection.Count); if (location is null) continue; width = location.Right - location.Left; @@ -506,7 +506,7 @@ public class D_Face : IFaceD } if (File.Exists(fileName)) File.Delete(fileName); - location = Shared.Models.Stateless.Methods.ILocation.GetLocation(_FaceDistanceHiddenImageFactor, face.Location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, source.Height, source.Width, collection.Count); + location = Shared.Models.Stateless.Methods.ILocation.GetLocation(_FaceDistanceHiddenImageFactor, face.Location, source.Height, source.Width, collection.Count); if (location is null) continue; width = location.Right - location.Left; diff --git a/FaceParts/Models/_D2_FaceParts.cs b/FaceParts/Models/_D2_FaceParts.cs index 755f29f..8dcfe09 100644 --- a/FaceParts/Models/_D2_FaceParts.cs +++ b/FaceParts/Models/_D2_FaceParts.cs @@ -214,7 +214,7 @@ public class D2_FaceParts bool updateDateWhenMatches = false; List<(Shared.Models.Face, string, string)> collection = []; string fileName = mappingFromItem.FilePath.NameWithoutExtension; - string[] changesFrom = [nameof(A_Property), nameof(B_Metadata), nameof(C_Resize), nameof(D_Face)]; + string[] changesFrom = [nameof(A_Metadata), nameof(C_Resize), nameof(D_Face)]; List dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList(); CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, filePath); string directory = _ResultContentFileGroups[0][cei.Enum][cei.Index]; diff --git a/Instance/DlibDotNet.cs b/Instance/DlibDotNet.cs index bfc4fa5..b992d35 100644 --- a/Instance/DlibDotNet.cs +++ b/Instance/DlibDotNet.cs @@ -31,6 +31,8 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable ReadOnlyCollection> FilePathsCollection, ReadOnlyDictionary? SplatNineIdentifiers); + public int? CurrentTick => + _ProgressBar?.CurrentTick; public long Ticks { get; init; } private readonly D_Face _Faces; @@ -87,7 +89,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions)); _BlurHasher = new BlurHash.Models.C2_BlurHasher(configuration.PropertyConfiguration); - string propertyRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(propertyConfiguration, nameof(A_Property), create: false); + string propertyRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(propertyConfiguration, nameof(A_Metadata), create: false); _PropertyRootExistedBefore = !Directory.Exists(propertyRoot); string argZero = args.Count > 0 ? Path.GetFullPath(args[0]) : Path.GetFullPath(propertyConfiguration.RootDirectory); _ArgZeroIsConfigurationRootDirectory = propertyConfiguration.RootDirectory == argZero; @@ -175,7 +177,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable _Logger?.LogInformation("First run completed. Run again if wanted"); } - private int FullParallelForWork(B_Metadata metadata, + private int FullParallelForWork(A_Metadata metadata, MapLogic mapLogic, string outputResolution, bool outputResolutionHasNumber, @@ -195,22 +197,22 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable long ticks = DateTime.Now.Ticks; DateTime dateTime = DateTime.Now; List parseExceptions = []; - string[] changesFrom = [nameof(A_Property)]; + string[] changesFrom = [nameof(A_Metadata)]; List> subFileTuples = []; FileHolder resizedFileHolder = _Resize.GetResizedFileHolder(cResultsFullGroupDirectory, item, outputResolutionHasNumber); if (item.ExifDirectory is null || item.ExifDirectory.FilePath?.Id is null) throw new Exception(); if (!item.SourceDirectoryFileHolder.Exists || item.SourceDirectoryFileHolder.CreationTime is null || item.SourceDirectoryFileHolder.LastWriteTime is null || item.Any()) throw new Exception(); - if (_Configuration.PropertyConfiguration.ForcePropertyLastWriteTimeToCreationTime && item.SourceDirectoryFileHolder.LastWriteTime.Value != item.SourceDirectoryFileHolder.CreationTime.Value) + if (item.SourceDirectoryFileHolder.LastWriteTime.Value != item.SourceDirectoryFileHolder.CreationTime.Value) { File.SetLastWriteTime(item.SourceDirectoryFileHolder.FullName, item.SourceDirectoryFileHolder.CreationTime.Value); - subFileTuples.Add(new Tuple(nameof(A_Property), item.SourceDirectoryFileHolder.CreationTime.Value)); + subFileTuples.Add(new Tuple(nameof(A_Metadata), item.SourceDirectoryFileHolder.CreationTime.Value)); } else if (item.SourceDirectoryFileHolder.LastWriteTime is not null) - subFileTuples.Add(new Tuple(nameof(A_Property), item.SourceDirectoryFileHolder.LastWriteTime.Value)); + subFileTuples.Add(new Tuple(nameof(A_Metadata), item.SourceDirectoryFileHolder.LastWriteTime.Value)); else - subFileTuples.Add(new Tuple(nameof(A_Property), new FileInfo(item.SourceDirectoryFileHolder.FullName).LastWriteTime)); + subFileTuples.Add(new Tuple(nameof(A_Metadata), new FileInfo(item.SourceDirectoryFileHolder.FullName).LastWriteTime)); if (resizedFileHolder.Exists && item.ExifDirectory.Width is not null && item.ExifDirectory.Width.Value > 4 && _Configuration.SaveBlurHashForOutputResolutions.Contains(outputResolution)) { string? file = _BlurHasher.GetFile(item.FilePath); @@ -323,7 +325,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable } private (int, bool) FullParallelWork(int maxDegreeOfParallelism, - B_Metadata metadata, + A_Metadata metadata, MapLogic mapLogic, string outputResolution, bool outputResolutionHasNumber, @@ -343,7 +345,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable DateTime[] containerDateTimes = Container.Models.Stateless.Methods.IContainer.GetContainerDateTimes(filteredItems); string focusRelativePath = Path.GetFullPath(string.Concat(_Configuration.PropertyConfiguration.RootDirectory, _Configuration.FocusDirectory)); bool? isFocusRelativePath = string.IsNullOrEmpty(_Configuration.FocusDirectory) ? null : container.SourceDirectory.StartsWith(focusRelativePath); - bool anyPropertiesChangedForX = _Configuration.PropertyConfiguration.PropertiesChangedForProperty || _Configuration.PropertiesChangedForDistance || _Configuration.PropertiesChangedForFaces || _Configuration.PropertiesChangedForIndex || _Configuration.PropertiesChangedForMetadata || _Configuration.PropertiesChangedForResize; + bool anyPropertiesChangedForX = _Configuration.PropertiesChangedForDistance || _Configuration.PropertiesChangedForFaces || _Configuration.PropertiesChangedForIndex || _Configuration.PropertiesChangedForMetadata || _Configuration.PropertiesChangedForResize; dlibDotNet.ConstructProgressBar(filteredItems.Count, message); _ = Parallel.For(0, filteredItems.Count, parallelOptions, (i, state) => { @@ -382,7 +384,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable string propertyRoot, string fPhotoPrismSingletonDirectory, int count, - B_Metadata metadata, + A_Metadata metadata, Record record, ReadOnlyCollection readOnlyContainers, MapLogic mapLogic) @@ -478,23 +480,16 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable GC.SuppressFinalize(this); } - (string, string) IDlibDotNet.GetResultsFullGroupDirectories() + string IDlibDotNet.GetResultsFullGroupDirectories() { - string aResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory( + string result = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory( _Configuration.PropertyConfiguration, - nameof(A_Property), + nameof(A_Metadata), string.Empty, includeResizeGroup: false, includeModel: false, includePredictorModel: false); - string bResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory( - _Configuration.PropertyConfiguration, - nameof(B_Metadata), - string.Empty, - includeResizeGroup: false, - includeModel: false, - includePredictorModel: false); - return new(aResultsFullGroupDirectory, bResultsFullGroupDirectory); + return new(result); } void IDlibDotNet.ConstructProgressBar(int maxTicks, string message) @@ -570,7 +565,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable if (filePath.Id is null) throw new Exception(); string[] directoryNames = keyValuePair.Value.Select(l => l.DirectoryFullPath.Replace('\\', '/')).ToArray(); - string paddedId = IId.GetPaddedId(propertyConfiguration, filePath.Id.Value, filePath.ExtensionLowered, filePath.HasIgnoreKeyword, filePath.HasDateTimeOriginal, index: null); + string paddedId = IId.GetPaddedId(propertyConfiguration, filePath, index: null); result = new(directoryNames, filePath.ExtensionLowered, filePath.HasDateTimeOriginal, filePath.Id.Value, filePath.Length, paddedId, filePath.LastWriteTicks); return result; } @@ -887,7 +882,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable return results.AsReadOnly(); } - private static ReadOnlyDictionary GetSplatNineIdentifiers(Property.Models.Configuration propertyConfiguration, string bResultsFullGroupDirectory, ReadOnlyDictionary> idToFilePaths) + private static ReadOnlyDictionary GetSplatNineIdentifiers(ILogger? logger, Property.Models.Configuration propertyConfiguration, string aResultsFullGroupDirectory, ReadOnlyDictionary> idToFilePaths) { Dictionary results = []; string json; @@ -895,7 +890,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable Identifier identifier; List identifiers = []; string rootDirectory = propertyConfiguration.RootDirectory.Replace('\\', '/'); - string bMetadataCollectionDirectory = Path.Combine(bResultsFullGroupDirectory, propertyConfiguration.ResultCollection); + string bMetadataCollectionDirectory = Path.Combine(aResultsFullGroupDirectory, propertyConfiguration.ResultCollection); if (!Directory.Exists(bMetadataCollectionDirectory)) _ = Directory.CreateDirectory(bMetadataCollectionDirectory); foreach (KeyValuePair> keyValuePair in idToFilePaths) @@ -924,13 +919,19 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable results.Add(keyValuePair.Key, identifier); } json = JsonSerializer.Serialize(results.Values.ToArray(), IdentifierCollectionSourceGenerationContext.Default.IdentifierArray); - _ = Shared.Models.Stateless.Methods.IPath.WriteAllText(Path.Combine(bMetadataCollectionDirectory, "!9.json"), json, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null); + if (Shared.Models.Stateless.Methods.IPath.WriteAllText(Path.Combine(bMetadataCollectionDirectory, "!9.json"), json, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null)) + logger?.LogWarning("!9.json has been updated!"); + else + logger?.LogInformation("!9.json matches"); json = JsonSerializer.Serialize((from l in identifiers orderby l.PaddedId select l).ToArray(), IdentifierCollectionSourceGenerationContext.Default.IdentifierArray); - _ = Shared.Models.Stateless.Methods.IPath.WriteAllText(Path.Combine(bMetadataCollectionDirectory, ".json"), json.Replace(rootDirectory, string.Empty), updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null); + if (Shared.Models.Stateless.Methods.IPath.WriteAllText(Path.Combine(bMetadataCollectionDirectory, ".json"), json.Replace(rootDirectory, string.Empty), updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null)) + logger?.LogWarning(".json has been updated!"); + else + logger?.LogInformation(".json matches"); return results.AsReadOnly(); } - private static ReadOnlyDictionary GetSplatNineIdentifiersAndHideSplatNine(Property.Models.Configuration propertyConfiguration, string bResultsFullGroupDirectory, ReadOnlyCollection> filePathsCollection) + private static ReadOnlyDictionary GetSplatNineIdentifiersAndHideSplatNine(ILogger? logger, Property.Models.Configuration propertyConfiguration, string aResultsFullGroupDirectory, ReadOnlyCollection> filePathsCollection) { ReadOnlyDictionary results; if (filePathsCollection.Count == 0) @@ -941,7 +942,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable ReadOnlyCollection moved = HideSplatNineAndGetMovedDuplicatesWithSameSplatNine(propertyConfiguration, idToFilePaths); if (moved.Count > 0) throw new Exception($"House cleaning needed!{Environment.NewLine}{string.Join(Environment.NewLine, moved.Select(l => l.Id))}"); - results = GetSplatNineIdentifiers(propertyConfiguration, bResultsFullGroupDirectory, idToFilePaths); + results = GetSplatNineIdentifiers(logger, propertyConfiguration, aResultsFullGroupDirectory, idToFilePaths); } return results; } @@ -1112,13 +1113,11 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable MapLogic? mapLogic; Record? record = null; string seasonDirectory; - A_Property propertyLogic; IDlibDotNet dlibDotNet = this; DateTime dateTime = new(Ticks); string eDistanceContentDirectory; string? a2PeopleContentDirectory; string aResultsFullGroupDirectory; - string bResultsFullGroupDirectory; string cResultsFullGroupDirectory; string fPhotoPrismContentDirectory; const string fileSearchFilter = "*"; @@ -1132,15 +1131,15 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable Path.Combine(_Configuration.PropertyConfiguration.RootDirectory, "Facebook"), Path.Combine(_Configuration.PropertyConfiguration.RootDirectory, "LinkedIn") ]; + aResultsFullGroupDirectory = dlibDotNet.GetResultsFullGroupDirectories(); bool runToDoCollectionFirst = GetRunToDoCollectionFirst(_Configuration, checkDirectories); - (aResultsFullGroupDirectory, bResultsFullGroupDirectory) = dlibDotNet.GetResultsFullGroupDirectories(); (int season, string seasonName) = Shared.Models.Stateless.Methods.IProperty.GetSeason(dateTime.DayOfYear); Shared.Models.Stateless.Methods.IPath.ChangeDateForEmptyDirectories(_Configuration.PropertyConfiguration.RootDirectory, dlibDotNet.Ticks); a2PeopleContentDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A2_People), "([])"); eDistanceContentDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(E_Distance), _Configuration.PropertyConfiguration.ResultContent); string a2PeopleSingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A2_People), _Configuration.PropertyConfiguration.ResultSingleton); _ = Directory.CreateDirectory(Path.Combine(eDistanceContentDirectory, dlibDotNet.Ticks.ToString())); - B_Metadata metadata = new(dlibDotNet, _Configuration.PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, dlibDotNet.Ticks, bResultsFullGroupDirectory); + A_Metadata metadata = new(dlibDotNet, _Configuration.PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, dlibDotNet.Ticks, aResultsFullGroupDirectory); if (runToDoCollectionFirst) mapLogic = null; else @@ -1152,12 +1151,11 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable configurationOutputResolutionsHas = true; if (!runToDoCollectionFirst) break; - record = GetFilesCollectionThenCopyOrMove(dlibDotNet, metadata, fileSearchFilter, directorySearchFilter, bResultsFullGroupDirectory, outputResolution); + record = GetFilesCollectionThenCopyOrMove(dlibDotNet, metadata, fileSearchFilter, directorySearchFilter, aResultsFullGroupDirectory, outputResolution); break; } fPhotoPrismContentDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(F_PhotoPrism), _Configuration.PropertyConfiguration.ResultContent); fPhotoPrismSingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(F_PhotoPrism), _Configuration.PropertyConfiguration.ResultSingleton); - propertyLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _Resize.FileNameExtension, _Configuration.Reverse, aResultsFullGroupDirectory); if (record is not null && record.FilesCollectionCountIsOne) { if (record.FilePathsCollection is null) @@ -1174,9 +1172,8 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable } argZero = SaveUrlAndGetNewRootDirectory(record.FilePathsCollection.First()); _Configuration.PropertyConfiguration.ChangeRootDirectory(argZero); - (aResultsFullGroupDirectory, bResultsFullGroupDirectory) = dlibDotNet.GetResultsFullGroupDirectories(); + aResultsFullGroupDirectory = dlibDotNet.GetResultsFullGroupDirectories(); propertyRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(_Configuration.PropertyConfiguration, nameof(A_Property), create: false); - propertyLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _Resize.FileNameExtension, _Configuration.Reverse, aResultsFullGroupDirectory); } if (configurationOutputResolutionsHas) { @@ -1230,7 +1227,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable { dlibDotNet.ConstructProgressBar(5, nameof(mapLogic.LookForAbandoned)); (cResultsFullGroupDirectory, _, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory) = dlibDotNet.GetResultsFullGroupDirectories(outputResolution); - mapLogic.LookForAbandoned(_Configuration.PropertyConfiguration, bResultsFullGroupDirectory, readOnlyContainers, cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory, dlibDotNet.Tick); + mapLogic.LookForAbandoned(_Configuration.PropertyConfiguration, aResultsFullGroupDirectory, readOnlyContainers, cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory, dlibDotNet.Tick); } } _Distance.Clear(); @@ -1271,7 +1268,6 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable string d2ResultsFullGroupDirectory; (cResultsFullGroupDirectory, c2ResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory) = dlibDotNet.GetResultsFullGroupDirectories(outputResolution); _ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(Path.Combine(aResultsFullGroupDirectory, _Configuration.PropertyConfiguration.ResultSingleton)); - _ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(Path.Combine(bResultsFullGroupDirectory, _Configuration.PropertyConfiguration.ResultSingleton)); _ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(Path.Combine(cResultsFullGroupDirectory, _Configuration.PropertyConfiguration.ResultSingleton)); if (_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Contains(outputResolution)) _ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(Path.Combine(dResultsFullGroupDirectory, _Configuration.PropertyConfiguration.ResultCollection)); @@ -1314,10 +1310,10 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable } } if (items.Count > 0) - throw new Exception($"{items.Count} item(s) of {count} item(s) are not setup!"); + throw new Exception($"{items.Count} item(s) of {count} item(s) are not setup!{Environment.NewLine}{string.Join(Environment.NewLine, items.Select(l => l.FilePath.FileNameFirstSegment))}"); } - private Record GetFilesCollectionThenCopyOrMove(IDlibDotNet dlibDotNet, B_Metadata metadata, string fileSearchFilter, string directorySearchFilter, string bResultsFullGroupDirectory, string outputResolution) + private Record GetFilesCollectionThenCopyOrMove(IDlibDotNet dlibDotNet, A_Metadata metadata, string fileSearchFilter, string directorySearchFilter, string aResultsFullGroupDirectory, string outputResolution) { Record result; int count; @@ -1329,7 +1325,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable string filesCollectionRootDirectory = _Configuration.PropertyConfiguration.RootDirectory; ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = maxDegreeOfParallelism }; (string cResultsFullGroupDirectory, _, _, _) = dlibDotNet.GetResultsFullGroupDirectories(outputResolution); - string jsonGroupDirectory = Path.Combine(bResultsFullGroupDirectory, _Configuration.PropertyConfiguration.ResultSingleton); + string jsonGroupDirectory = Path.Combine(aResultsFullGroupDirectory, _Configuration.PropertyConfiguration.ResultSingleton); if (!Directory.Exists(jsonGroupDirectory)) _ = Directory.CreateDirectory(jsonGroupDirectory); ReadOnlyDictionary>> keyValuePairs = @@ -1359,7 +1355,7 @@ public partial class DlibDotNet : IDlibDotNet, IDisposable message = $") Copying to ## pattern directory - {(int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - dlibDotNet.Ticks).TotalSeconds)} total second(s)"; dlibDotNet.ConstructProgressBar(count, message); _ = IDirectory.CopyOrMove(toDoCollection, move: false, moveBack: false, dlibDotNet.Tick); - ReadOnlyDictionary splatNineIdentifiers = GetSplatNineIdentifiersAndHideSplatNine(_Configuration.PropertyConfiguration, bResultsFullGroupDirectory, filePathsCollection); + ReadOnlyDictionary splatNineIdentifiers = GetSplatNineIdentifiersAndHideSplatNine(_Logger, _Configuration.PropertyConfiguration, aResultsFullGroupDirectory, filePathsCollection); result = new(ExifDirectoriesById: exifDirectoriesById, FilesCollectionRootDirectory: filesCollectionRootDirectory, FilesCollectionCountIsOne: filesCollectionCountIsOne, diff --git a/Map/Models/MapLogic.cs b/Map/Models/MapLogic.cs index 7aa7d70..77a344e 100644 --- a/Map/Models/MapLogic.cs +++ b/Map/Models/MapLogic.cs @@ -921,7 +921,7 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic return result; } - public void LookForAbandoned(Property.Models.Configuration propertyConfiguration, string bResultsFullGroupDirectory, ReadOnlyCollection readOnlyContainers, string cResultsFullGroupDirectory, string dResultsFullGroupDirectory, string d2ResultsFullGroupDirectory, Action? tick) + public void LookForAbandoned(Property.Models.Configuration propertyConfiguration, string aResultsFullGroupDirectory, ReadOnlyCollection readOnlyContainers, string cResultsFullGroupDirectory, string dResultsFullGroupDirectory, string d2ResultsFullGroupDirectory, Action? tick) { string[] directories; string? directoryName; @@ -929,7 +929,7 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic LookForAbandoned(propertyConfiguration, distinctFilteredIds); tick?.Invoke(); List distinctFilteredFileNameFirstSegments = Container.Models.Stateless.Methods.IContainer.GetFilteredDistinctFileNameFirstSegments(propertyConfiguration, readOnlyContainers); - Stateless.LookForAbandonedLogic.LookForAbandoned(propertyConfiguration, bResultsFullGroupDirectory, distinctFilteredFileNameFirstSegments); + Stateless.LookForAbandonedLogic.LookForAbandoned(propertyConfiguration, aResultsFullGroupDirectory, distinctFilteredFileNameFirstSegments); tick?.Invoke(); directories = Directory.GetDirectories(cResultsFullGroupDirectory, "*", SearchOption.TopDirectoryOnly); foreach (string directory in directories) diff --git a/Map/Models/Stateless/FaceFileLogic.cs b/Map/Models/Stateless/FaceFileLogic.cs index 28a2f00..5c8bac1 100644 --- a/Map/Models/Stateless/FaceFileLogic.cs +++ b/Map/Models/Stateless/FaceFileLogic.cs @@ -64,20 +64,19 @@ internal abstract class FaceFileLogic exifDirectory = Metadata.Models.Stateless.Methods.IMetadata.GetExifDirectory(mappedFile.FilePath); RectangleF? rectangle = ILocation.GetPercentagesRectangle(configuration.LocationDigits, wholePercentages.Value); personDisplayDirectoryName = mappedFile.PersonDisplayDirectoryName is null ? configuration.MappingDefaultName : mappedFile.PersonDisplayDirectoryName; - LocationContainer locationContainer = new(dateOnly, - exifDirectory, - mappedFile.DirectoryNumber, - personDisplayDirectoryName, - null, - null, - mappedFile.FilePath, - fromDistanceContent, - id.Value, - null, - null, - mappedFile.PersonKey, - rectangle, - wholePercentages.Value); + LocationContainer locationContainer = new(CreationDateOnly: dateOnly, + ExifDirectory: exifDirectory, + DirectoryNumber: mappedFile.DirectoryNumber, + DisplayDirectoryName: personDisplayDirectoryName, + Encoding: null, + FaceFile: null, + FilePath: mappedFile.FilePath, + FromDistanceContent: fromDistanceContent, + Id: id.Value, + LengthPermyriad: null, + LengthSource: null, + PersonKey: mappedFile.PersonKey, + WholePercentages: wholePercentages.Value); lock (locationContainers) locationContainers.Add(locationContainer); } @@ -167,23 +166,19 @@ internal abstract class FaceFileLogic MoveUnableToMatch(filePath); return; } - RectangleF? rectangle = ILocation.GetPercentagesRectangle(configuration.LocationDigits, wholePercentages.Value); - if (rectangle is null) - return; - LocationContainer locationContainer = new(dateOnly, - exifDirectory, - null, - null, - null, - faceFile, - filePath, - fromDistanceContent, - filePath.Id.Value, - null, - null, - null, - rectangle, - wholePercentages.Value); + LocationContainer locationContainer = new(CreationDateOnly: dateOnly, + ExifDirectory: exifDirectory, + DirectoryNumber: null, + DisplayDirectoryName: null, + Encoding: null, + FaceFile: faceFile, + FilePath: filePath, + FromDistanceContent: fromDistanceContent, + Id: filePath.Id.Value, + LengthPermyriad: null, + LengthSource: null, + PersonKey: null, + WholePercentages: wholePercentages.Value); lock (locationContainers) locationContainers.Add(locationContainer); } diff --git a/Map/Models/Stateless/LookForAbandonedLogic.cs b/Map/Models/Stateless/LookForAbandonedLogic.cs index ed0921a..d99c237 100644 --- a/Map/Models/Stateless/LookForAbandonedLogic.cs +++ b/Map/Models/Stateless/LookForAbandonedLogic.cs @@ -35,9 +35,9 @@ internal abstract class LookForAbandonedLogic } } - internal static void LookForAbandoned(Property.Models.Configuration propertyConfiguration, string bResultsFullGroupDirectory, List distinctFilteredFileNameFirstSegments) + internal static void LookForAbandoned(Property.Models.Configuration propertyConfiguration, string aResultsFullGroupDirectory, List distinctFilteredFileNameFirstSegments) { - string[] directories = Directory.GetDirectories(bResultsFullGroupDirectory, "*", SearchOption.TopDirectoryOnly); + string[] directories = Directory.GetDirectories(aResultsFullGroupDirectory, "*", SearchOption.TopDirectoryOnly); foreach (string directory in directories) { string? directoryName = Path.GetFileName(directory); diff --git a/Map/Models/Stateless/MapLogic.cs b/Map/Models/Stateless/MapLogic.cs index af68af6..5161e53 100644 --- a/Map/Models/Stateless/MapLogic.cs +++ b/Map/Models/Stateless/MapLogic.cs @@ -1152,22 +1152,20 @@ internal abstract class MapLogic exifDirectory = null; else exifDirectory = Metadata.Models.Stateless.Methods.IMetadata.GetExifDirectory(mappedFile.FilePath); - RectangleF? rectangle = ILocation.GetPercentagesRectangle(configuration.LocationDigits, wholePercentages.Value); personDisplayDirectoryName = mappedFile.PersonDisplayDirectoryName is null ? configuration.MappingDefaultName : mappedFile.PersonDisplayDirectoryName; - LocationContainer locationContainer = new(dateOnly, - exifDirectory, - mappedFile.DirectoryNumber, - personDisplayDirectoryName, - null, - null, - mappedFile.FilePath, - fromDistanceContent, - id.Value, - null, - null, - mappedFile.PersonKey, - rectangle, - wholePercentages.Value); + LocationContainer locationContainer = new(CreationDateOnly: dateOnly, + ExifDirectory: exifDirectory, + DirectoryNumber: mappedFile.DirectoryNumber, + DisplayDirectoryName: personDisplayDirectoryName, + Encoding: null, + FaceFile: null, + FilePath: mappedFile.FilePath, + FromDistanceContent: fromDistanceContent, + Id: id.Value, + LengthPermyriad: null, + LengthSource: null, + PersonKey: mappedFile.PersonKey, + WholePercentages: wholePercentages.Value); lock (locationContainers) locationContainers.Add(locationContainer); } @@ -1192,12 +1190,18 @@ internal abstract class MapLogic if (item.WholePercentages == locationContainer.WholePercentages) continue; itemPercentagesRectangle = ILocation.GetPercentagesRectangle(configuration.LocationDigits, item.WholePercentages); - if (itemPercentagesRectangle is null || locationContainer.Rectangle is null) + if (itemPercentagesRectangle is null) percent = null; else { - itemPercentagesArea = itemPercentagesRectangle.Value.Width * itemPercentagesRectangle.Value.Height; - percent = ILocation.GetIntersectPercent(itemPercentagesRectangle.Value, itemPercentagesArea, locationContainer.Rectangle.Value); + RectangleF? rectangle = ILocation.GetPercentagesRectangle(configuration.LocationDigits, item.WholePercentages); + if (rectangle is null) + percent = null; + else + { + itemPercentagesArea = itemPercentagesRectangle.Value.Width * itemPercentagesRectangle.Value.Height; + percent = ILocation.GetIntersectPercent(itemPercentagesRectangle.Value, itemPercentagesArea, rectangle.Value); + } } delete.Add(item.FilePath); delete.Add(locationContainer.FilePath); diff --git a/Metadata-Query/appsettings.json b/Metadata-Query/appsettings.json index 086a176..a1338ca 100644 --- a/Metadata-Query/appsettings.json +++ b/Metadata-Query/appsettings.json @@ -68,28 +68,54 @@ "ResultSingleton": "{}", "RootDirectory": "D:/Images", "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", ".nef", ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ] } } diff --git a/Metadata/Models/B_Metadata.cs b/Metadata/Models/A_Metadata.cs similarity index 94% rename from Metadata/Models/B_Metadata.cs rename to Metadata/Models/A_Metadata.cs index c46c380..a9c5c13 100644 --- a/Metadata/Models/B_Metadata.cs +++ b/Metadata/Models/A_Metadata.cs @@ -11,7 +11,7 @@ namespace View_by_Distance.Metadata.Models; /// // Dictionary>> /// -public class B_Metadata : IMetadata +public class A_Metadata : IMetadata { private readonly Dictionary _ExifDirectoriesById; @@ -32,14 +32,14 @@ public class B_Metadata : IMetadata private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions; private readonly ReadOnlyDictionary>[] _ResultSingletonFileGroups; - public B_Metadata(IDlibDotNet? dlibDotNet, IPropertyConfiguration propertyConfiguration, bool forceMetadataLastWriteTimeToCreationTime, bool propertiesChangedForMetadata, long ticks, string bResultsFullGroupDirectory) + public A_Metadata(IDlibDotNet? dlibDotNet, IPropertyConfiguration propertyConfiguration, bool forceMetadataLastWriteTimeToCreationTime, bool propertiesChangedForMetadata, long ticks, string aResultsFullGroupDirectory) { _PropertyConfiguration = propertyConfiguration; _PropertiesChangedForMetadata = propertiesChangedForMetadata; _ForceMetadataLastWriteTimeToCreationTime = forceMetadataLastWriteTimeToCreationTime; _ResultSingletonFileGroups = [new(new Dictionary>())]; _WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true }; - ReadOnlyDictionary>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, bResultsFullGroupDirectory, [propertyConfiguration.ResultSingleton]); + ReadOnlyDictionary>> keyValuePairs = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration, aResultsFullGroupDirectory, [propertyConfiguration.ResultSingleton]); foreach (KeyValuePair>> keyValuePair in keyValuePairs) { if (keyValuePair.Key == _PropertyConfiguration.ResultSingleton) @@ -56,13 +56,10 @@ public class B_Metadata : IMetadata Action? tick = dlibDotNet is null ? null : dlibDotNet.Tick; filesCollectionRootDirectory = propertyConfiguration.RootDirectory; ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = maxDegreeOfParallelism }; - string jsonGroupSingletonDirectory = Path.Combine(bResultsFullGroupDirectory, propertyConfiguration.ResultSingleton); - string jsonGroupCollectionDirectory = Path.Combine(bResultsFullGroupDirectory, propertyConfiguration.ResultCollection); - ReadOnlyCollection directories = new([jsonGroupSingletonDirectory, jsonGroupCollectionDirectory]); - Shared.Models.Stateless.Methods.IPath.CreateDirectories(directories); + string jsonGroupSingletonDirectory = Path.Combine(aResultsFullGroupDirectory, propertyConfiguration.ResultSingleton); ReadOnlyCollection> filePathsCollection = IDirectory.GetFilePathCollections(propertyConfiguration, directorySearchFilter, fileSearchFilter, filesCollectionRootDirectory, useIgnoreExtensions: true, useCeilingAverage: false); ReadOnlyCollection filePairs = IFilePair.GetFilePairs(propertyConfiguration, directorySearchFilter, extension, jsonGroupSingletonDirectory, filePathsCollection); - string message = $") {nameof(B_Metadata)} - Preloading ExifDirectory Dictionary - {(int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds)} total second(s)"; + string message = $") {nameof(A_Metadata)} - Preloading ExifDirectory Dictionary - {(int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds)} total second(s)"; dlibDotNet?.ConstructProgressBar(filePairs.Count, message); _ = Parallel.For(0, filePairs.Count, parallelOptions, (i, state) => ParallelFor(filePairs[i], exifDirectoriesById, tick)); _ExifDirectoriesById = exifDirectoriesById; @@ -156,12 +153,12 @@ public class B_Metadata : IMetadata result = JsonSerializer.Deserialize(json, ExifDirectorySourceGenerationContext.Default.ExifDirectory); if (result is null) throw new Exception(); - subFileTuples.Add(new Tuple(nameof(B_Metadata), fileInfo.LastWriteTime)); + subFileTuples.Add(new Tuple(nameof(A_Metadata), fileInfo.LastWriteTime)); } catch (Exception) { result = null; - parseExceptions.Add(nameof(B_Metadata)); + parseExceptions.Add(nameof(A_Metadata)); } } if (result is null) @@ -173,12 +170,12 @@ public class B_Metadata : IMetadata if (Shared.Models.Stateless.Methods.IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches, compareBeforeWrite: true, updateToWhenMatches: dateTime)) { if (!_ForceMetadataLastWriteTimeToCreationTime) - subFileTuples.Add(new Tuple(nameof(B_Metadata), DateTime.Now)); + subFileTuples.Add(new Tuple(nameof(A_Metadata), DateTime.Now)); else { File.SetLastWriteTime(fileInfo.FullName, fileInfo.CreationTime); fileInfo.Refresh(); - subFileTuples.Add(new Tuple(nameof(B_Metadata), fileInfo.CreationTime)); + subFileTuples.Add(new Tuple(nameof(A_Metadata), fileInfo.CreationTime)); } } } diff --git a/Metadata/Models/Stateless/Exif.cs b/Metadata/Models/Stateless/Exif.cs index 1851114..8e40144 100644 --- a/Metadata/Models/Stateless/Exif.cs +++ b/Metadata/Models/Stateless/Exif.cs @@ -28,22 +28,24 @@ internal abstract class Exif private static Shared.Models.AviDirectory[] GetAviDirectories(IReadOnlyList directories) { List results = []; + Shared.Models.AviDirectory aviDirectory; IEnumerable aviDirectories = directories.OfType(); - foreach (MetadataExtractor.Formats.Avi.AviDirectory aviDirectory in aviDirectories) + foreach (MetadataExtractor.Formats.Avi.AviDirectory a in aviDirectories) { - if (aviDirectory.Tags.Count == 0) + if (a.Tags.Count == 0) continue; DateTime? dateTimeOriginal; - string? duration = aviDirectory.GetDescription(MetadataExtractor.Formats.Avi.AviDirectory.TagDuration); - string? height = aviDirectory.GetDescription(MetadataExtractor.Formats.Avi.AviDirectory.TagHeight); - string? width = aviDirectory.GetDescription(MetadataExtractor.Formats.Avi.AviDirectory.TagWidth); - if (aviDirectory.TryGetDateTime(MetadataExtractor.Formats.Avi.AviDirectory.TagDateTimeOriginal, out DateTime checkDateTime)) + string? duration = a.GetDescription(MetadataExtractor.Formats.Avi.AviDirectory.TagDuration); + string? height = a.GetDescription(MetadataExtractor.Formats.Avi.AviDirectory.TagHeight); + string? width = a.GetDescription(MetadataExtractor.Formats.Avi.AviDirectory.TagWidth); + if (a.TryGetDateTime(MetadataExtractor.Formats.Avi.AviDirectory.TagDateTimeOriginal, out DateTime checkDateTime)) dateTimeOriginal = checkDateTime; else - dateTimeOriginal = GetDateTime(aviDirectory.GetString(MetadataExtractor.Formats.Avi.AviDirectory.TagDateTimeOriginal)); + dateTimeOriginal = GetDateTime(a.GetString(MetadataExtractor.Formats.Avi.AviDirectory.TagDateTimeOriginal)); if (dateTimeOriginal is null && duration is null && height is null && width is null) continue; - results.Add(new(dateTimeOriginal, duration, height, width)); + aviDirectory = new(DateTimeOriginal: dateTimeOriginal, Duration: duration, Height: height, Width: width); + results.Add(aviDirectory); } return results.ToArray(); } @@ -51,72 +53,73 @@ internal abstract class Exif private static Shared.Models.ExifDirectoryBase[] GetExifBaseDirectories(IReadOnlyList directories) { List results = []; + Shared.Models.ExifDirectoryBase exifDirectoryBase; IEnumerable exifBaseDirectories = directories.OfType(); - foreach (ExifDirectoryBase exifDirectoryBase in exifBaseDirectories) + foreach (ExifDirectoryBase e in exifBaseDirectories) { - if (exifDirectoryBase.Tags.Count == 0) + if (e.Tags.Count == 0) continue; DateTime? dateTime; DateTime checkDateTime; DateTime? dateTimeOriginal; DateTime? dateTimeDigitized; - string? aperture = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagAperture); - string? applicationNotes = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagApplicationNotes); - string? artist = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagArtist); - string? bitsPerSample = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagBitsPerSample); - string? bodySerialNumber = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagBodySerialNumber); - string? cameraOwnerName = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagCameraOwnerName); - string? compressedAverageBitsPerPixel = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagCompressedAverageBitsPerPixel); - string? compression = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagCompression); - string? copyright = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagCopyright); - string? documentName = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagDocumentName); - string? exifVersion = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagExifVersion); - string? exposureTime = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagExposureTime); - string? fileSource = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagFileSource); - string? imageDescription = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagImageDescription); - string? imageHeight = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagImageHeight); - int? imageHeightValue = imageHeight is null ? null : exifDirectoryBase.GetInt32(ExifDirectoryBase.TagImageHeight); - string? imageNumber = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagImageNumber); - string? imageUniqueId = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagImageUniqueId); - string? imageWidth = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagImageWidth); - int? imageWidthValue = imageWidth is null ? null : exifDirectoryBase.GetInt32(ExifDirectoryBase.TagImageWidth); - string? isoSpeed = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagIsoSpeed); - string? lensMake = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagLensMake); - string? lensModel = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagLensModel); - string? lensSerialNumber = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagLensSerialNumber); - string? make = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagMake); - string? makerNote = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagMakernote); - string? model = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagModel); - string? orientation = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagOrientation); - int? orientationValue = orientation is null ? null : exifDirectoryBase.GetInt32(ExifDirectoryBase.TagOrientation); - string? rating = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagRating); - string? ratingPercent = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagRatingPercent); - string? securityClassification = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagSecurityClassification); - string? shutterSpeed = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagShutterSpeed); - string? software = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagSoftware); - string? timeZone = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagTimeZone); - string? timeZoneDigitized = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagTimeZoneDigitized); - string? timeZoneOriginal = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagTimeZoneOriginal); - string? userComment = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagUserComment); - string? winAuthor = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagWinAuthor); - string? winComment = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagWinComment); - string? winKeywords = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagWinKeywords); - string? winSubject = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagWinSubject); - string? winTitle = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagWinTitle); - string? xResolution = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagXResolution); - string? yResolution = exifDirectoryBase.GetDescription(ExifDirectoryBase.TagYResolution); - if (exifDirectoryBase.TryGetDateTime(ExifDirectoryBase.TagDateTime, out checkDateTime)) + string? aperture = e.GetDescription(ExifDirectoryBase.TagAperture); + string? applicationNotes = e.GetDescription(ExifDirectoryBase.TagApplicationNotes); + string? artist = e.GetDescription(ExifDirectoryBase.TagArtist); + string? bitsPerSample = e.GetDescription(ExifDirectoryBase.TagBitsPerSample); + string? bodySerialNumber = e.GetDescription(ExifDirectoryBase.TagBodySerialNumber); + string? cameraOwnerName = e.GetDescription(ExifDirectoryBase.TagCameraOwnerName); + string? compressedAverageBitsPerPixel = e.GetDescription(ExifDirectoryBase.TagCompressedAverageBitsPerPixel); + string? compression = e.GetDescription(ExifDirectoryBase.TagCompression); + string? copyright = e.GetDescription(ExifDirectoryBase.TagCopyright); + string? documentName = e.GetDescription(ExifDirectoryBase.TagDocumentName); + string? exifVersion = e.GetDescription(ExifDirectoryBase.TagExifVersion); + string? exposureTime = e.GetDescription(ExifDirectoryBase.TagExposureTime); + string? fileSource = e.GetDescription(ExifDirectoryBase.TagFileSource); + string? imageDescription = e.GetDescription(ExifDirectoryBase.TagImageDescription); + string? imageHeight = e.GetDescription(ExifDirectoryBase.TagImageHeight); + int? imageHeightValue = imageHeight is null ? null : e.GetInt32(ExifDirectoryBase.TagImageHeight); + string? imageNumber = e.GetDescription(ExifDirectoryBase.TagImageNumber); + string? imageUniqueId = e.GetDescription(ExifDirectoryBase.TagImageUniqueId); + string? imageWidth = e.GetDescription(ExifDirectoryBase.TagImageWidth); + int? imageWidthValue = imageWidth is null ? null : e.GetInt32(ExifDirectoryBase.TagImageWidth); + string? isoSpeed = e.GetDescription(ExifDirectoryBase.TagIsoSpeed); + string? lensMake = e.GetDescription(ExifDirectoryBase.TagLensMake); + string? lensModel = e.GetDescription(ExifDirectoryBase.TagLensModel); + string? lensSerialNumber = e.GetDescription(ExifDirectoryBase.TagLensSerialNumber); + string? make = e.GetDescription(ExifDirectoryBase.TagMake); + string? makerNote = e.GetDescription(ExifDirectoryBase.TagMakernote); + string? model = e.GetDescription(ExifDirectoryBase.TagModel); + string? orientation = e.GetDescription(ExifDirectoryBase.TagOrientation); + int? orientationValue = orientation is null ? null : e.GetInt32(ExifDirectoryBase.TagOrientation); + string? rating = e.GetDescription(ExifDirectoryBase.TagRating); + string? ratingPercent = e.GetDescription(ExifDirectoryBase.TagRatingPercent); + string? securityClassification = e.GetDescription(ExifDirectoryBase.TagSecurityClassification); + string? shutterSpeed = e.GetDescription(ExifDirectoryBase.TagShutterSpeed); + string? software = e.GetDescription(ExifDirectoryBase.TagSoftware); + string? timeZone = e.GetDescription(ExifDirectoryBase.TagTimeZone); + string? timeZoneDigitized = e.GetDescription(ExifDirectoryBase.TagTimeZoneDigitized); + string? timeZoneOriginal = e.GetDescription(ExifDirectoryBase.TagTimeZoneOriginal); + string? userComment = e.GetDescription(ExifDirectoryBase.TagUserComment); + string? winAuthor = e.GetDescription(ExifDirectoryBase.TagWinAuthor); + string? winComment = e.GetDescription(ExifDirectoryBase.TagWinComment); + string? winKeywords = e.GetDescription(ExifDirectoryBase.TagWinKeywords); + string? winSubject = e.GetDescription(ExifDirectoryBase.TagWinSubject); + string? winTitle = e.GetDescription(ExifDirectoryBase.TagWinTitle); + string? xResolution = e.GetDescription(ExifDirectoryBase.TagXResolution); + string? yResolution = e.GetDescription(ExifDirectoryBase.TagYResolution); + if (e.TryGetDateTime(ExifDirectoryBase.TagDateTime, out checkDateTime)) dateTime = checkDateTime; else - dateTime = GetDateTime(exifDirectoryBase.GetString(ExifDirectoryBase.TagDateTime)); - if (exifDirectoryBase.TryGetDateTime(ExifDirectoryBase.TagDateTimeOriginal, out checkDateTime)) + dateTime = GetDateTime(e.GetString(ExifDirectoryBase.TagDateTime)); + if (e.TryGetDateTime(ExifDirectoryBase.TagDateTimeOriginal, out checkDateTime)) dateTimeOriginal = checkDateTime; else - dateTimeOriginal = GetDateTime(exifDirectoryBase.GetString(ExifDirectoryBase.TagDateTimeOriginal)); - if (exifDirectoryBase.TryGetDateTime(ExifDirectoryBase.TagDateTimeDigitized, out checkDateTime)) + dateTimeOriginal = GetDateTime(e.GetString(ExifDirectoryBase.TagDateTimeOriginal)); + if (e.TryGetDateTime(ExifDirectoryBase.TagDateTimeDigitized, out checkDateTime)) dateTimeDigitized = checkDateTime; else - dateTimeDigitized = GetDateTime(exifDirectoryBase.GetString(ExifDirectoryBase.TagDateTimeDigitized)); + dateTimeDigitized = GetDateTime(e.GetString(ExifDirectoryBase.TagDateTimeDigitized)); if (userComment is not null && userComment.Length > 255) userComment = "..."; if (aperture is null @@ -166,54 +169,55 @@ internal abstract class Exif && xResolution is not null && yResolution is null) continue; - results.Add(new(Aperture: aperture, - ApplicationNotes: applicationNotes, - Artist: artist, - BitsPerSample: bitsPerSample, - BodySerialNumber: bodySerialNumber, - CameraOwnerName: cameraOwnerName, - CompressedAverageBitsPerPixel: compressedAverageBitsPerPixel, - Compression: compression, - Copyright: copyright, - DateTime: dateTime, - DateTimeDigitized: dateTimeDigitized, - DateTimeOriginal: dateTimeOriginal, - DocumentName: documentName, - ExifVersion: exifVersion, - ExposureTime: exposureTime, - FileSource: fileSource, - ImageDescription: imageDescription, - ImageHeight: imageHeight, - ImageHeightValue: imageHeightValue, - ImageNumber: imageNumber, - ImageUniqueId: imageUniqueId, - ImageWidth: imageWidth, - ImageWidthValue: imageWidthValue, - IsoSpeed: isoSpeed, - LensMake: lensMake, - LensModel: lensModel, - LensSerialNumber: lensSerialNumber, - Make: make, - MakerNote: makerNote, - Model: model, - Orientation: orientation, - OrientationValue: orientationValue, - Rating: rating, - RatingPercent: ratingPercent, - SecurityClassification: securityClassification, - ShutterSpeed: shutterSpeed, - Software: software, - TimeZone: timeZone, - TimeZoneDigitized: timeZoneDigitized, - TimeZoneOriginal: timeZoneOriginal, - UserComment: userComment, - WinAuthor: winAuthor, - WinComment: winComment, - WinKeywords: winKeywords, - WinSubject: winSubject, - WinTitle: winTitle, - XResolution: xResolution, - YResolution: yResolution)); + exifDirectoryBase = new(Aperture: aperture, + ApplicationNotes: applicationNotes, + Artist: artist, + BitsPerSample: bitsPerSample, + BodySerialNumber: bodySerialNumber, + CameraOwnerName: cameraOwnerName, + CompressedAverageBitsPerPixel: compressedAverageBitsPerPixel, + Compression: compression, + Copyright: copyright, + DateTime: dateTime, + DateTimeDigitized: dateTimeDigitized, + DateTimeOriginal: dateTimeOriginal, + DocumentName: documentName, + ExifVersion: exifVersion, + ExposureTime: exposureTime, + FileSource: fileSource, + ImageDescription: imageDescription, + ImageHeight: imageHeight, + ImageHeightValue: imageHeightValue, + ImageNumber: imageNumber, + ImageUniqueId: imageUniqueId, + ImageWidth: imageWidth, + ImageWidthValue: imageWidthValue, + IsoSpeed: isoSpeed, + LensMake: lensMake, + LensModel: lensModel, + LensSerialNumber: lensSerialNumber, + Make: make, + MakerNote: makerNote, + Model: model, + Orientation: orientation, + OrientationValue: orientationValue, + Rating: rating, + RatingPercent: ratingPercent, + SecurityClassification: securityClassification, + ShutterSpeed: shutterSpeed, + Software: software, + TimeZone: timeZone, + TimeZoneDigitized: timeZoneDigitized, + TimeZoneOriginal: timeZoneOriginal, + UserComment: userComment, + WinAuthor: winAuthor, + WinComment: winComment, + WinKeywords: winKeywords, + WinSubject: winSubject, + WinTitle: winTitle, + XResolution: xResolution, + YResolution: yResolution); + results.Add(exifDirectoryBase); } return results.ToArray(); } @@ -221,23 +225,25 @@ internal abstract class Exif private static Shared.Models.FileMetadataDirectory[] GetFileMetadataDirectories(string file, IReadOnlyList directories) { List results = []; + Shared.Models.FileMetadataDirectory fileMetadataDirectory; IEnumerable fileMetadataDirectories = directories.OfType(); - foreach (MetadataExtractor.Formats.FileSystem.FileMetadataDirectory fileMetadataDirectory in fileMetadataDirectories) + foreach (MetadataExtractor.Formats.FileSystem.FileMetadataDirectory f in fileMetadataDirectories) { - if (fileMetadataDirectory.Tags.Count == 0) + if (f.Tags.Count == 0) continue; DateTime? fileModifiedDate; - string? fileName = fileMetadataDirectory.GetDescription(MetadataExtractor.Formats.FileSystem.FileMetadataDirectory.TagFileName); - string? fileSize = fileMetadataDirectory.GetDescription(MetadataExtractor.Formats.FileSystem.FileMetadataDirectory.TagFileSize); - if (fileMetadataDirectory.TryGetDateTime(MetadataExtractor.Formats.FileSystem.FileMetadataDirectory.TagFileModifiedDate, out DateTime checkDateTime)) + string? fileName = f.GetDescription(MetadataExtractor.Formats.FileSystem.FileMetadataDirectory.TagFileName); + string? fileSize = f.GetDescription(MetadataExtractor.Formats.FileSystem.FileMetadataDirectory.TagFileSize); + if (f.TryGetDateTime(MetadataExtractor.Formats.FileSystem.FileMetadataDirectory.TagFileModifiedDate, out DateTime checkDateTime)) fileModifiedDate = checkDateTime; else - fileModifiedDate = GetDateTime(fileMetadataDirectory.GetString(MetadataExtractor.Formats.FileSystem.FileMetadataDirectory.TagFileModifiedDate)); + fileModifiedDate = GetDateTime(f.GetString(MetadataExtractor.Formats.FileSystem.FileMetadataDirectory.TagFileModifiedDate)); if (fileName is null || !file.EndsWith(fileName)) throw new NotSupportedException($"!{file}.EndsWith({fileName})"); if (fileModifiedDate is null && fileName is null && fileSize is null) continue; - results.Add(new(fileModifiedDate, fileName, fileSize)); + fileMetadataDirectory = new(FileModifiedDate: fileModifiedDate, FileName: fileName, FileSize: fileSize); + results.Add(fileMetadataDirectory); } return results.ToArray(); } @@ -245,16 +251,18 @@ internal abstract class Exif private static Shared.Models.GifHeaderDirectory[] GetGifHeaderDirectories(IReadOnlyList directories) { List results = []; + Shared.Models.GifHeaderDirectory gifHeaderDirectory; IEnumerable gifHeaderDirectories = directories.OfType(); - foreach (MetadataExtractor.Formats.Gif.GifHeaderDirectory gifHeaderDirectory in gifHeaderDirectories) + foreach (MetadataExtractor.Formats.Gif.GifHeaderDirectory g in gifHeaderDirectories) { - if (gifHeaderDirectory.Tags.Count == 0) + if (g.Tags.Count == 0) continue; - string? imageHeight = gifHeaderDirectory.GetDescription(MetadataExtractor.Formats.Gif.GifHeaderDirectory.TagImageHeight); - string? imageWidth = gifHeaderDirectory.GetDescription(MetadataExtractor.Formats.Gif.GifHeaderDirectory.TagImageWidth); + string? imageHeight = g.GetDescription(MetadataExtractor.Formats.Gif.GifHeaderDirectory.TagImageHeight); + string? imageWidth = g.GetDescription(MetadataExtractor.Formats.Gif.GifHeaderDirectory.TagImageWidth); if (imageHeight is null && imageWidth is null) continue; - results.Add(new(imageHeight, imageWidth)); + gifHeaderDirectory = new(ImageHeight: imageHeight, ImageWidth: imageWidth); + results.Add(gifHeaderDirectory); } return results.ToArray(); } @@ -262,29 +270,31 @@ internal abstract class Exif private static Shared.Models.GpsDirectory[] GetGpsDirectories(IReadOnlyList directories) { List results = []; + Shared.Models.GpsDirectory gpsDirectory; IEnumerable gpsDirectories = directories.OfType(); - foreach (GpsDirectory gpsDirectory in gpsDirectories) + foreach (GpsDirectory g in gpsDirectories) { - if (gpsDirectory.Tags.Count == 0) + if (g.Tags.Count == 0) continue; DateTime? timeStamp; - string? altitude = gpsDirectory.GetDescription(GpsDirectory.TagAltitude); - string? latitude = gpsDirectory.GetDescription(GpsDirectory.TagLatitude); - string? latitudeRef = gpsDirectory.GetDescription(GpsDirectory.TagLatitudeRef); - string? longitude = gpsDirectory.GetDescription(GpsDirectory.TagLongitude); - string? longitudeRef = gpsDirectory.GetDescription(GpsDirectory.TagLongitudeRef); - if (gpsDirectory.TryGetDateTime(GpsDirectory.TagTimeStamp, out DateTime checkDateTime)) + string? altitude = g.GetDescription(GpsDirectory.TagAltitude); + string? latitude = g.GetDescription(GpsDirectory.TagLatitude); + string? latitudeRef = g.GetDescription(GpsDirectory.TagLatitudeRef); + string? longitude = g.GetDescription(GpsDirectory.TagLongitude); + string? longitudeRef = g.GetDescription(GpsDirectory.TagLongitudeRef); + if (g.TryGetDateTime(GpsDirectory.TagTimeStamp, out DateTime checkDateTime)) timeStamp = checkDateTime; else - timeStamp = GetDateTime(gpsDirectory.GetString(GpsDirectory.TagTimeStamp)); + timeStamp = GetDateTime(g.GetString(GpsDirectory.TagTimeStamp)); if (altitude is null && latitude is null && latitudeRef is null && longitude is null && longitudeRef is null && timeStamp is null) continue; - results.Add(new(altitude, - latitude, - latitudeRef, - longitude, - longitudeRef, - timeStamp)); + gpsDirectory = new(Altitude: altitude, + Latitude: latitude, + LatitudeRef: latitudeRef, + Longitude: longitude, + LongitudeRef: longitudeRef, + TimeStamp: timeStamp); + results.Add(gpsDirectory); } return results.ToArray(); } @@ -292,16 +302,18 @@ internal abstract class Exif private static Shared.Models.JpegDirectory[] GetJpegDirectories(IReadOnlyList directories) { List results = []; + Shared.Models.JpegDirectory jpegDirectory; IEnumerable jpegDirectories = directories.OfType(); - foreach (MetadataExtractor.Formats.Jpeg.JpegDirectory jpegDirectory in jpegDirectories) + foreach (MetadataExtractor.Formats.Jpeg.JpegDirectory j in jpegDirectories) { - if (jpegDirectory.Tags.Count == 0) + if (j.Tags.Count == 0) continue; - string? imageHeight = jpegDirectory.GetDescription(MetadataExtractor.Formats.Jpeg.JpegDirectory.TagImageHeight); - string? imageWidth = jpegDirectory.GetDescription(MetadataExtractor.Formats.Jpeg.JpegDirectory.TagImageWidth); + string? imageHeight = j.GetDescription(MetadataExtractor.Formats.Jpeg.JpegDirectory.TagImageHeight); + string? imageWidth = j.GetDescription(MetadataExtractor.Formats.Jpeg.JpegDirectory.TagImageWidth); if (imageHeight is null && imageWidth is null) continue; - results.Add(new(imageHeight, imageWidth)); + jpegDirectory = new(ImageHeight: imageHeight, ImageWidth: imageWidth); + results.Add(jpegDirectory); } return results.ToArray(); } @@ -309,6 +321,7 @@ internal abstract class Exif private static Shared.Models.MakernoteDirectory[] GetMakernoteDirectories(IReadOnlyList directories) { List results = []; + Shared.Models.MakernoteDirectory makernoteDirectory; IEnumerable appleMakernoteDirectories = directories.OfType(); foreach (AppleMakernoteDirectory appleMakernoteDirectory in appleMakernoteDirectories) { @@ -319,7 +332,8 @@ internal abstract class Exif string? qualityAndFileFormat = null; if (cameraSerialNumber is null && firmwareVersion is null && qualityAndFileFormat is null) continue; - results.Add(new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat)); + makernoteDirectory = new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat); + results.Add(makernoteDirectory); } IEnumerable canonMakernoteDirectories = directories.OfType(); foreach (CanonMakernoteDirectory canonMakernoteDirectory in canonMakernoteDirectories) @@ -331,7 +345,8 @@ internal abstract class Exif string? qualityAndFileFormat = canonMakernoteDirectory.GetDescription(CanonMakernoteDirectory.CameraSettings.TagQuality); if (cameraSerialNumber is null && firmwareVersion is null && qualityAndFileFormat is null) continue; - results.Add(new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat)); + makernoteDirectory = new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat); + results.Add(makernoteDirectory); } IEnumerable nikonType2MakernoteDirectories = directories.OfType(); foreach (NikonType2MakernoteDirectory nikonType2MakernoteDirectory in nikonType2MakernoteDirectories) @@ -343,7 +358,8 @@ internal abstract class Exif string? qualityAndFileFormat = nikonType2MakernoteDirectory.GetDescription(NikonType2MakernoteDirectory.TagQualityAndFileFormat); if (cameraSerialNumber is null && firmwareVersion is null && qualityAndFileFormat is null) continue; - results.Add(new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat)); + makernoteDirectory = new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat); + results.Add(makernoteDirectory); } IEnumerable olympusMakernoteDirectories = directories.OfType(); foreach (OlympusMakernoteDirectory olympusMakernoteDirectory in olympusMakernoteDirectories) @@ -355,7 +371,8 @@ internal abstract class Exif string? qualityAndFileFormat = olympusMakernoteDirectory.GetDescription(OlympusMakernoteDirectory.TagJpegQuality); if (cameraSerialNumber is null && firmwareVersion is null && qualityAndFileFormat is null) continue; - results.Add(new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat)); + makernoteDirectory = new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat); + results.Add(makernoteDirectory); } IEnumerable panasonicMakernoteDirectories = directories.OfType(); foreach (PanasonicMakernoteDirectory panasonicMakernoteDirectory in panasonicMakernoteDirectories) @@ -367,7 +384,8 @@ internal abstract class Exif string? qualityAndFileFormat = panasonicMakernoteDirectory.GetDescription(PanasonicMakernoteDirectory.TagQualityMode); if (cameraSerialNumber is null && firmwareVersion is null && qualityAndFileFormat is null) continue; - results.Add(new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat)); + makernoteDirectory = new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat); + results.Add(makernoteDirectory); } IEnumerable samsungType2MakernoteDirectories = directories.OfType(); foreach (SamsungType2MakernoteDirectory samsungType2MakernoteDirectory in samsungType2MakernoteDirectories) @@ -379,7 +397,8 @@ internal abstract class Exif string? qualityAndFileFormat = null; if (cameraSerialNumber is null && firmwareVersion is null && qualityAndFileFormat is null) continue; - results.Add(new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat)); + makernoteDirectory = new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat); + results.Add(makernoteDirectory); } IEnumerable sonyType6MakernoteDirectories = directories.OfType(); foreach (SonyType6MakernoteDirectory sonyType6MakernoteDirectory in sonyType6MakernoteDirectories) @@ -391,7 +410,8 @@ internal abstract class Exif string? qualityAndFileFormat = null; if (cameraSerialNumber is null && firmwareVersion is null && qualityAndFileFormat is null) continue; - results.Add(new(cameraSerialNumber, firmwareVersion, qualityAndFileFormat)); + makernoteDirectory = new(CameraSerialNumber: cameraSerialNumber, FirmwareVersion: firmwareVersion, QualityAndFileFormat: qualityAndFileFormat); + results.Add(makernoteDirectory); } return results.ToArray(); } @@ -399,16 +419,18 @@ internal abstract class Exif private static Shared.Models.PhotoshopDirectory[] GetPhotoshopDirectories(IReadOnlyList directories) { List results = []; + Shared.Models.PhotoshopDirectory photoshopDirectory; IEnumerable photoshopDirectories = directories.OfType(); - foreach (MetadataExtractor.Formats.Photoshop.PhotoshopDirectory photoshopDirectory in photoshopDirectories) + foreach (MetadataExtractor.Formats.Photoshop.PhotoshopDirectory p in photoshopDirectories) { - if (photoshopDirectory.Tags.Count == 0) + if (p.Tags.Count == 0) continue; - string? jpegQuality = photoshopDirectory.GetDescription(MetadataExtractor.Formats.Photoshop.PhotoshopDirectory.TagJpegQuality); - string? url = photoshopDirectory.GetDescription(MetadataExtractor.Formats.Photoshop.PhotoshopDirectory.TagUrl); + string? jpegQuality = p.GetDescription(MetadataExtractor.Formats.Photoshop.PhotoshopDirectory.TagJpegQuality); + string? url = p.GetDescription(MetadataExtractor.Formats.Photoshop.PhotoshopDirectory.TagUrl); if (jpegQuality is null && url is null) continue; - results.Add(new(jpegQuality, url)); + photoshopDirectory = new(JpegQuality: jpegQuality, Url: url); + results.Add(photoshopDirectory); } return results.ToArray(); } @@ -416,17 +438,19 @@ internal abstract class Exif private static Shared.Models.PngDirectory[] GetPngDirectories(IReadOnlyList directories) { List results = []; + Shared.Models.PngDirectory pngDirectory; IEnumerable pngDirectories = directories.OfType(); - foreach (MetadataExtractor.Formats.Png.PngDirectory pngDirectory in pngDirectories) + foreach (MetadataExtractor.Formats.Png.PngDirectory p in pngDirectories) { - if (pngDirectory.Tags.Count == 0) + if (p.Tags.Count == 0) continue; - string? imageHeight = pngDirectory.GetDescription(MetadataExtractor.Formats.Png.PngDirectory.TagImageHeight); - string? imageWidth = pngDirectory.GetDescription(MetadataExtractor.Formats.Png.PngDirectory.TagImageWidth); - string? textualData = pngDirectory.GetDescription(MetadataExtractor.Formats.Png.PngDirectory.TagTextualData); + string? imageHeight = p.GetDescription(MetadataExtractor.Formats.Png.PngDirectory.TagImageHeight); + string? imageWidth = p.GetDescription(MetadataExtractor.Formats.Png.PngDirectory.TagImageWidth); + string? textualData = p.GetDescription(MetadataExtractor.Formats.Png.PngDirectory.TagTextualData); if (imageHeight is null && imageWidth is null && textualData is null) continue; - results.Add(new(imageHeight, imageWidth, textualData)); + pngDirectory = new(ImageHeight: imageHeight, ImageWidth: imageWidth, TextualData: textualData); + results.Add(pngDirectory); } return results.ToArray(); } @@ -434,19 +458,21 @@ internal abstract class Exif private static Shared.Models.QuickTimeMovieHeaderDirectory[] GetQuickTimeMovieHeaderDirectoryDirectories(IReadOnlyList directories) { List results = []; + Shared.Models.QuickTimeMovieHeaderDirectory quickTimeMovieHeaderDirectory; IEnumerable quickTimeMovieHeaderDirectories = directories.OfType(); - foreach (MetadataExtractor.Formats.QuickTime.QuickTimeMovieHeaderDirectory quickTimeMovieHeaderDirectory in quickTimeMovieHeaderDirectories) + foreach (MetadataExtractor.Formats.QuickTime.QuickTimeMovieHeaderDirectory q in quickTimeMovieHeaderDirectories) { - if (quickTimeMovieHeaderDirectory.Tags.Count == 0) + if (q.Tags.Count == 0) continue; DateTime? created; - if (quickTimeMovieHeaderDirectory.TryGetDateTime(MetadataExtractor.Formats.QuickTime.QuickTimeMovieHeaderDirectory.TagCreated, out DateTime checkDateTime)) + if (q.TryGetDateTime(MetadataExtractor.Formats.QuickTime.QuickTimeMovieHeaderDirectory.TagCreated, out DateTime checkDateTime)) created = checkDateTime; else - created = GetDateTime(quickTimeMovieHeaderDirectory.GetString(MetadataExtractor.Formats.QuickTime.QuickTimeMovieHeaderDirectory.TagCreated)); + created = GetDateTime(q.GetString(MetadataExtractor.Formats.QuickTime.QuickTimeMovieHeaderDirectory.TagCreated)); if (created is null) continue; - results.Add(new(created)); + quickTimeMovieHeaderDirectory = new(Created: created); + results.Add(quickTimeMovieHeaderDirectory); } return results.ToArray(); } @@ -454,19 +480,21 @@ internal abstract class Exif private static Shared.Models.QuickTimeTrackHeaderDirectory[] GetQuickTimeTrackHeaderDirectoryDirectories(IReadOnlyList directories) { List results = []; + Shared.Models.QuickTimeTrackHeaderDirectory quickTimeTrackHeaderDirectory; IEnumerable quickTimeTrackHeaderDirectories = directories.OfType(); - foreach (MetadataExtractor.Formats.QuickTime.QuickTimeTrackHeaderDirectory quickTimeTrackHeaderDirectory in quickTimeTrackHeaderDirectories) + foreach (MetadataExtractor.Formats.QuickTime.QuickTimeTrackHeaderDirectory q in quickTimeTrackHeaderDirectories) { - if (quickTimeTrackHeaderDirectory.Tags.Count == 0) + if (q.Tags.Count == 0) continue; DateTime? created; - if (quickTimeTrackHeaderDirectory.TryGetDateTime(MetadataExtractor.Formats.QuickTime.QuickTimeTrackHeaderDirectory.TagCreated, out DateTime checkDateTime)) + if (q.TryGetDateTime(MetadataExtractor.Formats.QuickTime.QuickTimeTrackHeaderDirectory.TagCreated, out DateTime checkDateTime)) created = checkDateTime; else - created = GetDateTime(quickTimeTrackHeaderDirectory.GetString(MetadataExtractor.Formats.QuickTime.QuickTimeTrackHeaderDirectory.TagCreated)); + created = GetDateTime(q.GetString(MetadataExtractor.Formats.QuickTime.QuickTimeTrackHeaderDirectory.TagCreated)); if (created is null) continue; - results.Add(new(created)); + quickTimeTrackHeaderDirectory = new(Created: created); + results.Add(quickTimeTrackHeaderDirectory); } return results.ToArray(); } @@ -474,16 +502,18 @@ internal abstract class Exif private static Shared.Models.WebPDirectory[] GetWebPDirectories(IReadOnlyList directories) { List results = []; + Shared.Models.WebPDirectory webPDirectory; IEnumerable webPDirectories = directories.OfType(); - foreach (MetadataExtractor.Formats.WebP.WebPDirectory webPDirectory in webPDirectories) + foreach (MetadataExtractor.Formats.WebP.WebPDirectory w in webPDirectories) { - if (webPDirectory.Tags.Count == 0) + if (w.Tags.Count == 0) continue; - string? imageHeight = webPDirectory.GetDescription(MetadataExtractor.Formats.WebP.WebPDirectory.TagImageHeight); - string? imageWidth = webPDirectory.GetDescription(MetadataExtractor.Formats.WebP.WebPDirectory.TagImageWidth); + string? imageHeight = w.GetDescription(MetadataExtractor.Formats.WebP.WebPDirectory.TagImageHeight); + string? imageWidth = w.GetDescription(MetadataExtractor.Formats.WebP.WebPDirectory.TagImageWidth); if (imageHeight is null && imageWidth is null) continue; - results.Add(new(imageHeight, imageWidth)); + webPDirectory = new(ImageHeight: imageHeight, ImageWidth: imageWidth); + results.Add(webPDirectory); } return results.ToArray(); } diff --git a/Metadata/Models/Stateless/Face.cs b/Metadata/Models/Stateless/Face.cs index 8cb08b1..c967ef1 100644 --- a/Metadata/Models/Stateless/Face.cs +++ b/Metadata/Models/Stateless/Face.cs @@ -1,3 +1,4 @@ +using System.Text.Json; using View_by_Distance.Shared.Models; namespace View_by_Distance.Metadata.Models.Stateless.Methods; @@ -5,6 +6,14 @@ namespace View_by_Distance.Metadata.Models.Stateless.Methods; internal static class Face { + internal static FaceEncoding? GetFaceEncoding(ExifDirectory? exifDirectory) + { + FaceEncoding? result; + string? json = GetFaceEncoding(exifDirectory?.PngDirectories); + result = string.IsNullOrEmpty(json) ? null : JsonSerializer.Deserialize(json, FaceEncodingGenerationContext.Default.FaceEncoding); + return result; + } + internal static string? GetFaceEncoding(PngDirectory[]? pngDirectories) { string? result = null; @@ -22,6 +31,14 @@ internal static class Face return result; } + internal static FaceFile? GetFaceFile(ExifDirectory? exifDirectory) + { + FaceFile? result; + string? json = GetOutputResolution(exifDirectory?.PngDirectories); + result = string.IsNullOrEmpty(json) ? null : JsonSerializer.Deserialize(json, FaceFileGenerationContext.Default.FaceFile); + return result; + } + internal static string? GetOutputResolution(PngDirectory[]? pngDirectories) { string? result = null; diff --git a/Metadata/Models/Stateless/Methods/IMetadata.cs b/Metadata/Models/Stateless/Methods/IMetadata.cs index 0ae7b22..4a9c1b0 100644 --- a/Metadata/Models/Stateless/Methods/IMetadata.cs +++ b/Metadata/Models/Stateless/Methods/IMetadata.cs @@ -14,44 +14,46 @@ public interface IMetadata Meters } - ExifDirectory TestStatic_GetExifDirectory(FilePath filePath) => - GetExifDirectory(filePath); - static ExifDirectory GetExifDirectory(FilePath filePath) => + public static ExifDirectory GetExifDirectory(FilePath filePath) => Exif.GetExifDirectory(filePath); - string? TestStatic_GetOutputResolution(ExifDirectory? exifDirectory) => - GetOutputResolution(exifDirectory); - static string? GetOutputResolution(ExifDirectory? exifDirectory) => - Face.GetOutputResolution(exifDirectory?.PngDirectories); + public static FaceFile? GetFaceFile(ExifDirectory? exifDirectory) => + Face.GetFaceFile(exifDirectory); - string? TestStatic_GetFaceEncoding(ExifDirectory? exifDirectory) => - GetFaceEncoding(exifDirectory); - static string? GetFaceEncoding(ExifDirectory? exifDirectory) => - Face.GetFaceEncoding(exifDirectory?.PngDirectories); - - GeoLocation? TestStatic_GeoLocation(ExifDirectory? exifDirectory) => - GeoLocation(exifDirectory); - static GeoLocation? GeoLocation(ExifDirectory? exifDirectory) => + public static GeoLocation? GeoLocation(ExifDirectory? exifDirectory) => GPS.GeoLocation(exifDirectory?.GpsDirectories); - double? TestStatic_GetDistance(double originLatitude, double originLongitude, double destinationLatitude, double destinationLongitude, int decimalPlaces = 1, DistanceUnit distanceUnit = DistanceUnit.Miles) => - GetDistance(originLatitude, originLongitude, destinationLatitude, destinationLongitude, decimalPlaces, distanceUnit); - static double? GetDistance(double originLatitude, double originLongitude, double destinationLatitude, double destinationLongitude, int decimalPlaces = 1, DistanceUnit distanceUnit = DistanceUnit.Miles) => + public static string? GetOutputResolution(ExifDirectory? exifDirectory) => + Face.GetOutputResolution(exifDirectory?.PngDirectories); + + public static string? GetRawFaceEncoding(ExifDirectory? exifDirectory) => + Face.GetFaceEncoding(exifDirectory?.PngDirectories); + + public static FaceEncoding? GetFaceEncoding(ExifDirectory? exifDirectory) => + Face.GetFaceEncoding(exifDirectory); + + public static double? GetDistance(double originLatitude, double originLongitude, double destinationLatitude, double destinationLongitude, int decimalPlaces = 1, DistanceUnit distanceUnit = DistanceUnit.Miles) => GPS.GetDistance(originLatitude, originLongitude, destinationLatitude, destinationLongitude, decimalPlaces, distanceUnit); - // string? TestStatic_GetFaceEncoding(IReadOnlyList directories) => - // GetFaceEncoding(directories); - // static string? GetFaceEncoding(IReadOnlyList directories) => - // Metadata.GetFaceEncoding(directories); + internal ExifDirectory TestStatic_GetExifDirectory(FilePath filePath) => + GetExifDirectory(filePath); - // string? TestStatic_GetOutputResolution(IReadOnlyList directories) => - // GetOutputResolution(directories); - // static string? GetOutputResolution(IReadOnlyList directories) => - // Metadata.GetOutputResolution(directories); + internal GeoLocation? TestStatic_GeoLocation(ExifDirectory? exifDirectory) => + GeoLocation(exifDirectory); - // Dictionary TestStatic_GetMetadataCollection(FileInfo fileInfo, List> subFileTuples, List parseExceptions) => - // GetMetadataCollection(fileInfo, subFileTuples, parseExceptions); - // static Dictionary GetMetadataCollection(FileInfo fileInfo, List> subFileTuples, List parseExceptions) => - // Metadata.GetMetadataCollection(fileInfo, subFileTuples, parseExceptions); + internal string? TestStatic_GetRawFaceEncoding(ExifDirectory? exifDirectory) => + GetRawFaceEncoding(exifDirectory); + + internal string? TestStatic_GetOutputResolution(ExifDirectory? exifDirectory) => + GetOutputResolution(exifDirectory); + + internal static FaceFile? TestStatic_GetFaceFile(ExifDirectory? exifDirectory) => + GetFaceFile(exifDirectory); + + internal FaceEncoding? TestStatic_GetFaceEncoding(ExifDirectory? exifDirectory) => + GetFaceEncoding(exifDirectory); + + internal double? TestStatic_GetDistance(double originLatitude, double originLongitude, double destinationLatitude, double destinationLongitude, int decimalPlaces = 1, DistanceUnit distanceUnit = DistanceUnit.Miles) => + GetDistance(originLatitude, originLongitude, destinationLatitude, destinationLongitude, decimalPlaces, distanceUnit); } \ No newline at end of file diff --git a/Mirror-Length/appsettings.json b/Mirror-Length/appsettings.json index 086a176..a1338ca 100644 --- a/Mirror-Length/appsettings.json +++ b/Mirror-Length/appsettings.json @@ -68,28 +68,54 @@ "ResultSingleton": "{}", "RootDirectory": "D:/Images", "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", ".nef", ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ] } } diff --git a/Offset-Date-Time-Original/appsettings.json b/Offset-Date-Time-Original/appsettings.json index e733c41..ad7b14a 100644 --- a/Offset-Date-Time-Original/appsettings.json +++ b/Offset-Date-Time-Original/appsettings.json @@ -67,28 +67,54 @@ "ResultSingleton": "{}", "RootDirectory": "D:/Images", "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", ".nef", ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ] } } diff --git a/PrepareForOld/appsettings.Development.json b/PrepareForOld/appsettings.Development.json index a709607..613b88a 100644 --- a/PrepareForOld/appsettings.Development.json +++ b/PrepareForOld/appsettings.Development.json @@ -60,12 +60,34 @@ "PropertiesChangedForProperty": false, "RootDirectory": "C:/Tmp/Phares/Pictures", "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", ".nef", ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "PropertyContentCollectionFiles": [], "Spelling": [ @@ -95,20 +117,24 @@ "September" ], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ], "VerifyToSeason": [ ". 2000", diff --git a/Property/Models/Binder/Configuration.cs b/Property/Models/Binder/Configuration.cs index 9c87a25..03a6e95 100644 --- a/Property/Models/Binder/Configuration.cs +++ b/Property/Models/Binder/Configuration.cs @@ -9,7 +9,6 @@ public class Configuration public string? DateGroup { get; set; } public string? FileNameDirectorySeparator { get; set; } - public bool? ForcePropertyLastWriteTimeToCreationTime { get; set; } public string[]? IgnoreExtensions { get; set; } public string[]? IgnoreRulesKeyWords { get; set; } public int? IntMinValueLength { get; set; } @@ -64,7 +63,6 @@ public class Configuration if (configuration is null) throw new NullReferenceException(nameof(configuration)); if (configuration.DateGroup is null) throw new NullReferenceException(nameof(configuration.DateGroup)); if (configuration.FileNameDirectorySeparator is null) throw new NullReferenceException(nameof(configuration.FileNameDirectorySeparator)); - if (configuration.ForcePropertyLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForcePropertyLastWriteTimeToCreationTime)); if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions)); if (configuration.IgnoreRulesKeyWords is null) throw new NullReferenceException(nameof(configuration.IgnoreRulesKeyWords)); if (configuration.IntMinValueLength is null) throw new NullReferenceException(nameof(configuration.IntMinValueLength)); @@ -89,33 +87,31 @@ public class Configuration if (configuration.ValidImageFormatExtensions is null) throw new NullReferenceException(nameof(configuration.ValidImageFormatExtensions)); if (configuration.ValidVideoFormatExtensions is null) throw new NullReferenceException(nameof(configuration.ValidVideoFormatExtensions)); // if (configuration.VerifyToSeason is null) throw new NullReferenceException(nameof(configuration.VerifyToSeason)); - result = new(configuration.DateGroup, - configuration.FileNameDirectorySeparator, - configuration.ForcePropertyLastWriteTimeToCreationTime.Value, - configuration.IgnoreExtensions, - configuration.IgnoreRulesKeyWords, - configuration.IntMinValueLength.Value, - configuration.MaxImagesInDirectoryForTopLevelFirstPass.Value, - configuration.ModelName, - configuration.NumberOfJitters, - configuration.NumberOfTimesToUpsample, - configuration.Offset.Value, - configuration.Pattern, - configuration.PersonBirthdayFormat, - configuration.PopulatePropertyId.Value, - configuration.PredictorModelName, - configuration.PropertiesChangedForProperty.Value, - configuration.PropertyContentCollectionFiles ?? [], - configuration.ResultAllInOne, - configuration.ResultAllInOneSubdirectoryLength.Value, - configuration.ResultCollection, - configuration.ResultContent, - configuration.ResultContentCollection, - configuration.ResultSingleton, - Path.GetFullPath(configuration.RootDirectory), - configuration.ValidImageFormatExtensions, - configuration.ValidVideoFormatExtensions, - configuration.VerifyToSeason ?? []); + result = new(dateGroup: configuration.DateGroup, + fileNameDirectorySeparator: configuration.FileNameDirectorySeparator, + ignoreExtensions: configuration.IgnoreExtensions, + ignoreRulesKeyWords: configuration.IgnoreRulesKeyWords, + intMinValueLength: configuration.IntMinValueLength.Value, + maxImagesInDirectoryForTopLevelFirstPass: configuration.MaxImagesInDirectoryForTopLevelFirstPass.Value, + modelName: configuration.ModelName, + numberOfJitters: configuration.NumberOfJitters, + numberOfTimesToUpsample: configuration.NumberOfTimesToUpsample, + offset: configuration.Offset.Value, + pattern: configuration.Pattern, + personBirthdayFormat: configuration.PersonBirthdayFormat, + populatePropertyId: configuration.PopulatePropertyId.Value, + predictorModelName: configuration.PredictorModelName, + propertyContentCollectionFiles: configuration.PropertyContentCollectionFiles ?? [], + resultAllInOne: configuration.ResultAllInOne, + resultAllInOneSubdirectoryLength: configuration.ResultAllInOneSubdirectoryLength.Value, + resultCollection: configuration.ResultCollection, + resultContent: configuration.ResultContent, + resultContentCollection: configuration.ResultContentCollection, + resultSingleton: configuration.ResultSingleton, + rootDirectory: Path.GetFullPath(configuration.RootDirectory), + validImageFormatExtensions: configuration.ValidImageFormatExtensions, + validVideoFormatExtensions: configuration.ValidVideoFormatExtensions, + verifyToSeason: configuration.VerifyToSeason ?? []); return result; } diff --git a/Property/Models/Configuration.cs b/Property/Models/Configuration.cs index 55b3c15..a1ae152 100644 --- a/Property/Models/Configuration.cs +++ b/Property/Models/Configuration.cs @@ -12,7 +12,6 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration public string DateGroup { init; get; } public string FileNameDirectorySeparator { init; get; } - public bool ForcePropertyLastWriteTimeToCreationTime { init; get; } public string[] IgnoreExtensions { init; get; } public string[] IgnoreRulesKeyWords { init; get; } public int IntMinValueLength { init; get; } @@ -25,7 +24,6 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration public string PersonBirthdayFormat { init; get; } public bool PopulatePropertyId { init; get; } public string? PredictorModelName { init; get; } - public bool PropertiesChangedForProperty { init; get; } public string[] PropertyContentCollectionFiles { init; get; } public string ResultAllInOne { init; get; } public int ResultAllInOneSubdirectoryLength { init; get; } @@ -39,7 +37,6 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration [JsonConstructor] public Configuration(string dateGroup, string fileNameDirectorySeparator, - bool forcePropertyLastWriteTimeToCreationTime, string[] ignoreExtensions, string[] ignoreRulesKeyWords, int intMinValueLength, @@ -52,7 +49,6 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration string personBirthdayFormat, bool populatePropertyId, string? predictorModelName, - bool propertiesChangedForProperty, string[] propertyContentCollectionFiles, string resultAllInOne, int resultAllInOneSubdirectoryLength, @@ -67,7 +63,6 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration { DateGroup = dateGroup; FileNameDirectorySeparator = fileNameDirectorySeparator; - ForcePropertyLastWriteTimeToCreationTime = forcePropertyLastWriteTimeToCreationTime; IgnoreExtensions = ignoreExtensions; IgnoreRulesKeyWords = ignoreRulesKeyWords; IntMinValueLength = intMinValueLength; @@ -80,7 +75,6 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration PersonBirthdayFormat = personBirthdayFormat; PredictorModelName = predictorModelName; PopulatePropertyId = populatePropertyId; - PropertiesChangedForProperty = propertiesChangedForProperty; PropertyContentCollectionFiles = propertyContentCollectionFiles; ResultAllInOne = resultAllInOne; ResultAllInOneSubdirectoryLength = resultAllInOneSubdirectoryLength; diff --git a/Rename/.vscode/appsettings.example.json b/Rename/.vscode/appsettings.example.json index d3fe436..9458893 100644 --- a/Rename/.vscode/appsettings.example.json +++ b/Rename/.vscode/appsettings.example.json @@ -82,28 +82,54 @@ "xxxRootDirectory": "D:/1-Images-A/Images-dd514b88/Facebook/2023.3 Facebook", "RootDirectory": "D:/7-Question/California", "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", ".nef", ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ] } }, diff --git a/Rename/Rename.cs b/Rename/Rename.cs index e857ed8..6b5256c 100644 --- a/Rename/Rename.cs +++ b/Rename/Rename.cs @@ -85,7 +85,7 @@ public class Rename const bool useCeilingAverage = false; const string directorySearchFilter = "*"; List distinctDirectories = []; - B_Metadata metadata = new(_PropertyConfiguration); + A_Metadata metadata = new(_PropertyConfiguration); List<(FileHolder, string, string)> toDoCollection = []; List<(FileHolder, string)> verifiedToDoCollection = []; ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true }; @@ -209,7 +209,7 @@ public class Rename return results; } - private List GetRecords(B_Metadata metadata, int offset, ProgressBar progressBar, string[] files) + private List GetRecords(A_Metadata metadata, int offset, ProgressBar progressBar, string[] files) { List results = []; int? id; diff --git a/Resize/Models/_C_Resize.cs b/Resize/Models/_C_Resize.cs index b93d1ab..180f7bd 100644 --- a/Resize/Models/_C_Resize.cs +++ b/Resize/Models/_C_Resize.cs @@ -195,7 +195,7 @@ public class C_Resize { Dictionary? results; string json; - string[] changesFrom = [nameof(A_Property), nameof(B_Metadata)]; + string[] changesFrom = [nameof(A_Metadata)]; List dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList(); CombinedEnumAndIndex cei = Shared.Models.Stateless.Methods.IPath.GetCombinedEnumAndIndex(_PropertyConfiguration, filePath); string fileName = $"{mappingFromItem.FilePath.NameWithoutExtension}{mappingFromItem.FilePath.ExtensionLowered}.json"; @@ -353,7 +353,7 @@ public class C_Resize int outputResolutionHeight = resize[_OutputResolutionHeightIndex]; int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex]; int[] originalCollection = outputResolutionToResize[_Original]; - string[] changesFrom = [nameof(A_Property), nameof(B_Metadata), nameof(C_Resize)]; + string[] changesFrom = [nameof(A_Metadata), nameof(C_Resize)]; List dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList(); if (_OverrideForResizeImages) check = true; diff --git a/Set-Created-Date/SetCreatedDate.cs b/Set-Created-Date/SetCreatedDate.cs index b608ec0..6af3f74 100644 --- a/Set-Created-Date/SetCreatedDate.cs +++ b/Set-Created-Date/SetCreatedDate.cs @@ -64,7 +64,7 @@ public class SetCreatedDate { } } - private List GetRecords(ProgressBar progressBar, ASCIIEncoding asciiEncoding, B_Metadata metadata, string[] files) + private List GetRecords(ProgressBar progressBar, ASCIIEncoding asciiEncoding, A_Metadata metadata, string[] files) { List results = []; int? id; @@ -101,9 +101,9 @@ public class SetCreatedDate int minutes; Record[] records; List unordered; - ASCIIEncoding asciiEncoding = new(); - B_Metadata metadata = new(_PropertyConfiguration); List collections = []; + ASCIIEncoding asciiEncoding = new(); + A_Metadata metadata = new(_PropertyConfiguration); foreach (string[] files in filesCollection) { minutes = 0; diff --git a/Set-Created-Date/appsettings.json b/Set-Created-Date/appsettings.json index bafa145..626125b 100644 --- a/Set-Created-Date/appsettings.json +++ b/Set-Created-Date/appsettings.json @@ -69,28 +69,54 @@ "ResultSingleton": "{}", "RootDirectory": "D:/Images", "IgnoreExtensions": [ + ".ffs_db", + ".FFS_DB", ".gif", ".GIF", + ".heic", + ".HEIC", + ".html", + ".HTML", + ".ico", + ".ICO", + ".json", + ".JSON", + ".lnk", + ".LNK", + ".lsv", + ".LSV", ".nef", ".NEF", ".pdf", - ".PDF" + ".PDF", + ".ts", + ".TS", + ".txt", + ".TXT", + ".webp", + ".WEBP", + ".xmp", + ".XMP" ], "ValidImageFormatExtensions": [ + ".avif", ".bmp", - ".BMP", ".gif", - ".GIF", + ".heic", + ".insp", + ".jp2", + ".jpe", ".jpeg", - ".JPEG", ".jpg", - ".JPG", + ".jxl", ".png", - ".PNG", - ".tiff", - ".TIFF", + ".psd", + ".raw", + ".rw2", + ".svg", ".tif", - ".TIF" + ".tiff", + ".webp" ] } } diff --git a/Shared/Models/Location.cs b/Shared/Models/Location.cs index bff202c..bfe6ac1 100644 --- a/Shared/Models/Location.cs +++ b/Shared/Models/Location.cs @@ -23,7 +23,7 @@ public class Location : Properties.ILocation, IEquatable _ = Stateless.Methods.Location.Check(bottom, left, right, top, zCount: 1, throwException: true); } - public Location(double confidence, int height, Location location, int locationDigits, int locationFactor, int width, int zCount) : + public Location(double confidence, int height, Location location, int width, int zCount) : this( location.Bottom, confidence, @@ -32,7 +32,7 @@ public class Location : Properties.ILocation, IEquatable location.Top) => Stateless.Methods.Location.Check(Bottom, height, Left, Right, Top, width, zCount, throwException: true); - public Location(int bottom, double confidence, int height, int left, int locationDigits, int locationFactor, int right, int top, int width, int zCount) : + public Location(int bottom, double confidence, int height, int left, int right, int top, int width, int zCount) : this( bottom, confidence, @@ -41,7 +41,7 @@ public class Location : Properties.ILocation, IEquatable top) => Stateless.Methods.Location.Check(Bottom, height, Left, Right, Top, width, zCount, throwException: true); - public Location(int height, Location location, int locationDigits, int locationFactor, int width, int zCount) : + public Location(int height, Location location, int width, int zCount) : this( location.Bottom, location.Confidence, @@ -50,7 +50,7 @@ public class Location : Properties.ILocation, IEquatable location.Top) => Stateless.Methods.Location.Check(Bottom, height, Left, Right, Top, width, zCount, throwException: true); - public Location(double confidence, int factor, int height, Location location, int locationDigits, int locationFactor, int width, int zCount) + public Location(double confidence, int factor, int height, Location location, int width, int zCount) { int x = (location.Right - location.Left) / factor; int y = (location.Bottom - location.Top) / factor; diff --git a/Shared/Models/LocationContainer.cs b/Shared/Models/LocationContainer.cs index 8918861..7dfef97 100644 --- a/Shared/Models/LocationContainer.cs +++ b/Shared/Models/LocationContainer.cs @@ -1,5 +1,3 @@ -using System.Drawing; - namespace View_by_Distance.Shared.Models; public record LocationContainer(DateOnly CreationDateOnly, @@ -14,47 +12,44 @@ public record LocationContainer(DateOnly CreationDateOnly, int? LengthPermyriad, FilePath? LengthSource, long? PersonKey, - RectangleF? Rectangle, int WholePercentages) { public static LocationContainer Get(LocationContainer locationContainer, object? encoding, bool keepExifDirectory) { LocationContainer result; - result = new(locationContainer.CreationDateOnly, - keepExifDirectory ? locationContainer.ExifDirectory : null, - locationContainer.DirectoryNumber, - locationContainer.DisplayDirectoryName, - encoding, - locationContainer.FaceFile, - locationContainer.FilePath, - locationContainer.FromDistanceContent, - locationContainer.Id, - locationContainer.LengthPermyriad, - locationContainer.LengthSource, - locationContainer.PersonKey, - locationContainer.Rectangle, - locationContainer.WholePercentages); + result = new(CreationDateOnly: locationContainer.CreationDateOnly, + ExifDirectory: keepExifDirectory ? locationContainer.ExifDirectory : null, + DirectoryNumber: locationContainer.DirectoryNumber, + DisplayDirectoryName: locationContainer.DisplayDirectoryName, + Encoding: encoding, + FaceFile: locationContainer.FaceFile, + FilePath: locationContainer.FilePath, + FromDistanceContent: locationContainer.FromDistanceContent, + Id: locationContainer.Id, + LengthPermyriad: locationContainer.LengthPermyriad, + LengthSource: locationContainer.LengthSource, + PersonKey: locationContainer.PersonKey, + WholePercentages: locationContainer.WholePercentages); return result; } public static LocationContainer Get(LocationContainer source, LocationContainer locationContainer, int lengthPermyriad, bool keepExifDirectory, bool keepEncoding) { LocationContainer result; - result = new(locationContainer.CreationDateOnly, - keepExifDirectory ? locationContainer.ExifDirectory : null, - locationContainer.DirectoryNumber, - locationContainer.DisplayDirectoryName, - keepEncoding ? locationContainer.Encoding : null, - locationContainer.FaceFile, - locationContainer.FilePath, - locationContainer.FromDistanceContent, - locationContainer.Id, - lengthPermyriad, - source.FilePath, - locationContainer.PersonKey, - locationContainer.Rectangle, - locationContainer.WholePercentages); + result = new(CreationDateOnly: locationContainer.CreationDateOnly, + ExifDirectory: keepExifDirectory ? locationContainer.ExifDirectory : null, + DirectoryNumber: locationContainer.DirectoryNumber, + DisplayDirectoryName: locationContainer.DisplayDirectoryName, + Encoding: keepEncoding ? locationContainer.Encoding : null, + FaceFile: locationContainer.FaceFile, + FilePath: locationContainer.FilePath, + FromDistanceContent: locationContainer.FromDistanceContent, + Id: locationContainer.Id, + LengthPermyriad: lengthPermyriad, + LengthSource: source.FilePath, + PersonKey: locationContainer.PersonKey, + WholePercentages: locationContainer.WholePercentages); return result; } diff --git a/Shared/Models/Properties/IPropertyConfiguration.cs b/Shared/Models/Properties/IPropertyConfiguration.cs index 0039228..a7c80ff 100644 --- a/Shared/Models/Properties/IPropertyConfiguration.cs +++ b/Shared/Models/Properties/IPropertyConfiguration.cs @@ -8,7 +8,6 @@ public interface IPropertyConfiguration public string[] IgnoreRulesKeyWords { init; get; } public int IntMinValueLength { init; get; } public string PersonBirthdayFormat { init; get; } - public bool PropertiesChangedForProperty { init; get; } public string[] PropertyContentCollectionFiles { init; get; } public string ResultAllInOne { init; get; } public int ResultAllInOneSubdirectoryLength { init; get; } diff --git a/Shared/Models/Stateless/Methods/IDlibDotNet.cs b/Shared/Models/Stateless/Methods/IDlibDotNet.cs index a1fe46c..4480a18 100644 --- a/Shared/Models/Stateless/Methods/IDlibDotNet.cs +++ b/Shared/Models/Stateless/Methods/IDlibDotNet.cs @@ -5,7 +5,8 @@ public interface IDlibDotNet void Tick(); long Ticks { get; } - (string, string) GetResultsFullGroupDirectories(); + int? CurrentTick { get; } + string GetResultsFullGroupDirectories(); void ConstructProgressBar(int maxTicks, string message); (string, string, string, string) GetResultsFullGroupDirectories(string outputResolution); diff --git a/Shared/Models/Stateless/Methods/IId.cs b/Shared/Models/Stateless/Methods/IId.cs index 44ecdf6..70ac9f1 100644 --- a/Shared/Models/Stateless/Methods/IId.cs +++ b/Shared/Models/Stateless/Methods/IId.cs @@ -19,6 +19,9 @@ public interface IId public static bool IsOffsetDeterministicHashCode(IPropertyConfiguration propertyConfiguration) => propertyConfiguration.Offset == DeterministicHashCode; + public static string GetIntelligentId(IPropertyConfiguration propertyConfiguration, FilePath filePath) => + Id.GetIntelligentId(propertyConfiguration, filePath); + public static byte GetHasDateTimeOriginal(IPropertyConfiguration propertyConfiguration, FilePath filePath) => Id.GetHasDateTimeOriginal(propertyConfiguration, filePath); @@ -31,16 +34,19 @@ public interface IId public static bool NameWithoutExtensionIsIntelligentIdFormat(IPropertyConfiguration propertyConfiguration, string fileNameFirstSegment) => fileNameFirstSegment.Length - 1 == propertyConfiguration.IntMinValueLength && fileNameFirstSegment[^1] is '0' or '1' or '2' or '3' or '4' or '5' or '6' or '7' or '8' or '9' && fileNameFirstSegment.All(char.IsNumber); - public static string GetIntelligentId(IPropertyConfiguration propertyConfiguration, long id, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal) => - Id.GetIntelligentId(propertyConfiguration, id, extensionLowered, hasIgnoreKeyword, hasDateTimeOriginal); + public static string? GetPaddedId(IPropertyConfiguration propertyConfiguration, FilePath filePath, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) => + Id.GetPaddedId(propertyConfiguration, filePath, hasIgnoreKeyword, hasDateTimeOriginal, index); public static bool NameWithoutExtensionIsPaddedIntelligentIdFormat(IPropertyConfiguration propertyConfiguration, int sortOrderOnlyLengthIndex, string fileNameFirstSegment) => fileNameFirstSegment.Length == propertyConfiguration.IntMinValueLength + sortOrderOnlyLengthIndex + 1 && fileNameFirstSegment[^1] is '0' or '1' or '2' or '3' or '4' or '5' or '6' or '7' or '8' or '9' && fileNameFirstSegment.All(char.IsNumber); - public static string GetPaddedId(IPropertyConfiguration propertyConfiguration, int id, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) => - Id.GetPaddedId(propertyConfiguration, id, extensionLowered, hasIgnoreKeyword, hasDateTimeOriginal, index); + public static string? GetPaddedId(IPropertyConfiguration propertyConfiguration, int id, string nameWithoutExtension, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) => + Id.GetPaddedId(propertyConfiguration, id, nameWithoutExtension, extensionLowered, hasIgnoreKeyword, hasDateTimeOriginal, index); + + public static string GetPaddedId(IPropertyConfiguration propertyConfiguration, FilePath filePath, int? index) => + Id.GetPaddedId(propertyConfiguration, filePath, index); internal int TestStatic_GetDeterministicHashCode(byte[] value) => GetDeterministicHashCode(value); @@ -51,9 +57,15 @@ public interface IId internal int TestStatic_GetId(IPropertyConfiguration propertyConfiguration, string intelligentId) => GetId(propertyConfiguration, intelligentId); + internal string TestStatic_GetIntelligentId(IPropertyConfiguration propertyConfiguration, FilePath filePath) => + GetIntelligentId(propertyConfiguration, filePath); + internal byte TestStatic_GetHasDateTimeOriginal(IPropertyConfiguration propertyConfiguration, FilePath filePath) => GetHasDateTimeOriginal(propertyConfiguration, filePath); + internal string TestStatic_GetPaddedId(IPropertyConfiguration propertyConfiguration, FilePath filePath, int? index) => + GetPaddedId(propertyConfiguration, filePath, index); + internal byte TestStatic_GetMissingDateTimeOriginal(IPropertyConfiguration propertyConfiguration, FilePath filePath) => GetMissingDateTimeOriginal(propertyConfiguration, filePath); @@ -63,13 +75,13 @@ public interface IId internal bool TestStatic_NameWithoutExtensionIsIntelligentIdFormat(IPropertyConfiguration propertyConfiguration, string fileNameFirstSegment) => NameWithoutExtensionIsIntelligentIdFormat(propertyConfiguration, fileNameFirstSegment); - internal string TestStatic_GetIntelligentId(IPropertyConfiguration propertyConfiguration, long id, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal) => - GetIntelligentId(propertyConfiguration, id, extensionLowered, hasIgnoreKeyword, hasDateTimeOriginal); + internal string? TestStatic_GetPaddedId(IPropertyConfiguration propertyConfiguration, FilePath filePath, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) => + GetPaddedId(propertyConfiguration, filePath, hasIgnoreKeyword, hasDateTimeOriginal, index); internal bool TestStatic_NameWithoutExtensionIsPaddedIntelligentIdFormat(IPropertyConfiguration propertyConfiguration, int sortOrderOnlyLengthIndex, string fileNameFirstSegment) => NameWithoutExtensionIsPaddedIntelligentIdFormat(propertyConfiguration, sortOrderOnlyLengthIndex, fileNameFirstSegment); - internal string TestStatic_GetPaddedId(IPropertyConfiguration propertyConfiguration, int id, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) => - GetPaddedId(propertyConfiguration, id, extensionLowered, hasIgnoreKeyword, hasDateTimeOriginal, index); + internal string? TestStatic_GetPaddedId(IPropertyConfiguration propertyConfiguration, int id, string nameWithoutExtension, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) => + GetPaddedId(propertyConfiguration, id, nameWithoutExtension, extensionLowered, hasIgnoreKeyword, hasDateTimeOriginal, index); } \ No newline at end of file diff --git a/Shared/Models/Stateless/Methods/ILocation.cs b/Shared/Models/Stateless/Methods/ILocation.cs index 8c27447..14d562c 100644 --- a/Shared/Models/Stateless/Methods/ILocation.cs +++ b/Shared/Models/Stateless/Methods/ILocation.cs @@ -55,15 +55,15 @@ public interface ILocation static string GetLeftPadded(int locationDigits, int value) => GetLeftPadded(locationDigits, value.ToString()); - Models.Location? TestStatic_GetLocation(Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) => - GetLocation(location, locationDigits, locationFactor, height, width, zCount); - static Models.Location? GetLocation(Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) => - location is null ? null : new(location.Confidence, height, location, locationDigits, locationFactor, width, zCount); + Models.Location? TestStatic_GetLocation(Models.Location? location, int height, int width, int zCount) => + GetLocation(location, height, width, zCount); + static Models.Location? GetLocation(Models.Location? location, int height, int width, int zCount) => + location is null ? null : new(location.Confidence, height, location, width, zCount); - Models.Location? TestStatic_GetLocation(int factor, Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) => - GetLocation(factor, location, locationDigits, locationFactor, height, width, zCount); - static Models.Location? GetLocation(int factor, Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) => - location is null ? null : new(location.Confidence, factor, height, location, locationDigits, locationFactor, width, zCount); + Models.Location? TestStatic_GetLocation(int factor, Models.Location? location, int height, int width, int zCount) => + GetLocation(factor, location, height, width, zCount); + static Models.Location? GetLocation(int factor, Models.Location? location, int height, int width, int zCount) => + location is null ? null : new(location.Confidence, factor, height, location, width, zCount); (decimal?, decimal?, decimal?, decimal?) TestStatic_GetHeightLeftTopWidth(int bottom, int height, int left, int right, int top, int width) => GetHeightLeftTopWidth(bottom, height, left, right, top, width); @@ -107,8 +107,6 @@ public interface ILocation detectionConfidence, height, Math.Max(rectangle.Left, 0), - Stateless.ILocation.Digits, - Stateless.ILocation.Factor, Math.Min(rectangle.Right, width), Math.Max(rectangle.Top, 0), width, diff --git a/Shared/Models/Stateless/Methods/IPath.cs b/Shared/Models/Stateless/Methods/IPath.cs index 8ecc5d5..4ab786d 100644 --- a/Shared/Models/Stateless/Methods/IPath.cs +++ b/Shared/Models/Stateless/Methods/IPath.cs @@ -24,9 +24,6 @@ public interface IPath public static void MakeHiddenIfAllItemsAreHidden(string rootDirectory) => XPath.MakeHiddenIfAllItemsAreHidden(rootDirectory); - public static void CreateDirectories(ReadOnlyCollection directories) => - XPath.CreateDirectories(directories); - public static void ChangeDateForEmptyDirectories(string rootDirectory, long ticks) => XPath.ChangeDateForEmptyDirectories(rootDirectory, ticks); @@ -68,9 +65,6 @@ public interface IPath internal void TestStatic_MakeHiddenIfAllItemsAreHidden(string rootDirectory) => MakeHiddenIfAllItemsAreHidden(rootDirectory); - internal void TestStatic_CreateDirectories(ReadOnlyCollection directories) => - CreateDirectories(directories); - internal void TestStatic_ChangeDateForEmptyDirectories(string rootDirectory, long ticks) => ChangeDateForEmptyDirectories(rootDirectory, ticks); diff --git a/Shared/Models/Stateless/Methods/Id.cs b/Shared/Models/Stateless/Methods/Id.cs index 3c75879..0784041 100644 --- a/Shared/Models/Stateless/Methods/Id.cs +++ b/Shared/Models/Stateless/Methods/Id.cs @@ -1,4 +1,5 @@ using System.Text; +using View_by_Distance.Shared.Models.Properties; namespace View_by_Distance.Shared.Models.Stateless.Methods; @@ -27,7 +28,26 @@ internal abstract class Id internal static byte GetHasIgnoreKeyword(FilePath filePath) => (byte)(filePath.Id > -1 ? 8 : 2); - internal static int GetId(Properties.IPropertyConfiguration propertyConfiguration, string intelligentId) + internal static byte GetHasDateTimeOriginal(IPropertyConfiguration propertyConfiguration, FilePath filePath) => + (byte)(IsIgnoreOrValidVideoFormatExtension(propertyConfiguration, filePath) ? filePath.Id > -1 ? 6 : 4 : filePath.Id > -1 ? 9 : 1); + + private static string GetExtension(string nameWithoutExtension, string extensionLowered) => + extensionLowered is not ".xmp" and not ".json" ? extensionLowered : Path.GetExtension(nameWithoutExtension); + + private static string GetExtension(FilePath filePath) => + GetExtension(filePath.NameWithoutExtension, filePath.ExtensionLowered); + + private static bool IsIgnoreOrValidVideoFormatExtension(IPropertyConfiguration propertyConfiguration, FilePath filePath) => + IsIgnoreOrValidVideoFormatExtension(propertyConfiguration, GetExtension(filePath)); + + private static bool IsIgnoreOrValidVideoFormatExtension(IPropertyConfiguration propertyConfiguration, string extensionLowered) => + propertyConfiguration.IgnoreExtensions.Contains(extensionLowered) + || propertyConfiguration.ValidVideoFormatExtensions.Contains(extensionLowered); + + internal static byte GetMissingDateTimeOriginal(IPropertyConfiguration propertyConfiguration, FilePath filePath) => + (byte)(IsIgnoreOrValidVideoFormatExtension(propertyConfiguration, filePath) ? filePath.Id > -1 ? 5 : 0 : filePath.Id > -1 ? 7 : 3); + + internal static int GetId(IPropertyConfiguration propertyConfiguration, string intelligentId) { int result; StringBuilder results = new(); @@ -44,13 +64,7 @@ internal abstract class Id return result; } - internal static byte GetHasDateTimeOriginal(Properties.IPropertyConfiguration propertyConfiguration, FilePath filePath) => - (byte)(propertyConfiguration.IgnoreExtensions.Contains(filePath.ExtensionLowered) || propertyConfiguration.ValidVideoFormatExtensions.Contains(filePath.ExtensionLowered) ? filePath.Id > -1 ? 6 : 4 : filePath.Id > -1 ? 9 : 1); - - internal static byte GetMissingDateTimeOriginal(Properties.IPropertyConfiguration propertyConfiguration, FilePath filePath) => - (byte)(propertyConfiguration.IgnoreExtensions.Contains(filePath.ExtensionLowered) || propertyConfiguration.ValidVideoFormatExtensions.Contains(filePath.ExtensionLowered) ? filePath.Id > -1 ? 5 : 0 : filePath.Id > -1 ? 7 : 3); - - internal static bool NameWithoutExtensionIsIdFormat(Properties.IPropertyConfiguration propertyConfiguration, string fileNameWithoutExtension) + internal static bool NameWithoutExtensionIsIdFormat(IPropertyConfiguration propertyConfiguration, string fileNameWithoutExtension) { bool result; if (fileNameWithoutExtension.Length < 5 || fileNameWithoutExtension.Length > propertyConfiguration.IntMinValueLength) @@ -63,7 +77,7 @@ internal abstract class Id return result; } - internal static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal) + internal static string GetIntelligentId(IPropertyConfiguration propertyConfiguration, long id, string nameWithoutExtension, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal) { string result; StringBuilder stringBuilder = new(); @@ -79,18 +93,20 @@ internal abstract class Id } else if (id > -1) { - if (!propertyConfiguration.ValidVideoFormatExtensions.Contains(extensionLowered)) - key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? 8 : hasDateTimeOriginal.Value ? 9 : 7; - else + string checkExtension = GetExtension(nameWithoutExtension, extensionLowered); + if (IsIgnoreOrValidVideoFormatExtension(propertyConfiguration, checkExtension)) key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? throw new NotImplementedException() : hasDateTimeOriginal.Value ? 6 : 5; + else + key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? 8 : hasDateTimeOriginal.Value ? 9 : 7; value = id.ToString().PadLeft(propertyConfiguration.IntMinValueLength, '0'); } else { - if (!propertyConfiguration.ValidVideoFormatExtensions.Contains(extensionLowered)) - key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? 2 : hasDateTimeOriginal.Value ? 1 : 3; - else + string checkExtension = GetExtension(nameWithoutExtension, extensionLowered); + if (IsIgnoreOrValidVideoFormatExtension(propertyConfiguration, checkExtension)) key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? throw new NotImplementedException() : hasDateTimeOriginal.Value ? 4 : 0; + else + key = hasIgnoreKeyword is not null && hasIgnoreKeyword.Value ? 2 : hasDateTimeOriginal.Value ? 1 : 3; value = id.ToString()[1..].PadLeft(propertyConfiguration.IntMinValueLength, '0'); } for (int i = value.Length - propertyConfiguration.ResultAllInOneSubdirectoryLength - 1; i > -1; i--) @@ -101,14 +117,51 @@ internal abstract class Id return result; } - internal static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int id, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) + internal static string GetIntelligentId(IPropertyConfiguration propertyConfiguration, FilePath filePath) => + filePath.Id is null ? throw new Exception() : GetIntelligentId(propertyConfiguration, filePath.Id.Value, filePath.NameWithoutExtension, filePath.ExtensionLowered, filePath.HasIgnoreKeyword, filePath.HasDateTimeOriginal); + + internal static string GetPaddedId(IPropertyConfiguration propertyConfiguration, FilePath filePath, int? index) { string result; if (propertyConfiguration.Offset < 0) result = Guid.NewGuid().ToString(); else { - string intelligentId = GetIntelligentId(propertyConfiguration, id, extensionLowered, hasIgnoreKeyword, hasDateTimeOriginal); + string intelligentId = GetIntelligentId(propertyConfiguration, filePath); + int check = GetId(propertyConfiguration, intelligentId); + if (filePath.Id is not null && check != filePath.Id.Value) + throw new NotSupportedException(); + result = index is null || propertyConfiguration.Offset == IId.DeterministicHashCode ? intelligentId : $"{propertyConfiguration.Offset + index}{intelligentId}"; + } + return result; + } + + internal static string? GetPaddedId(IPropertyConfiguration propertyConfiguration, FilePath filePath, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) + { + string? result; + if (filePath.Id is null) + result = null; + else if (propertyConfiguration.Offset < 0) + result = Guid.NewGuid().ToString(); + else + { + string intelligentId = GetIntelligentId(propertyConfiguration, filePath.Id.Value, filePath.NameWithoutExtension, filePath.ExtensionLowered, hasIgnoreKeyword, hasDateTimeOriginal); + int check = GetId(propertyConfiguration, intelligentId); + if (filePath.Id is not null && check != filePath.Id.Value) + throw new NotSupportedException(); + result = index is null || propertyConfiguration.Offset == IId.DeterministicHashCode ? intelligentId : $"{propertyConfiguration.Offset + index}{intelligentId}"; + } + return result; + } + + internal static string GetPaddedId(IPropertyConfiguration propertyConfiguration, int id, string nameWithoutExtension, string extensionLowered, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) + { + string result; + if (propertyConfiguration.Offset < 0) + result = Guid.NewGuid().ToString(); + else + { + string intelligentId = GetIntelligentId(propertyConfiguration, id, nameWithoutExtension, extensionLowered, hasIgnoreKeyword, hasDateTimeOriginal); int check = GetId(propertyConfiguration, intelligentId); if (check != id) throw new NotSupportedException(); diff --git a/Shared/Models/Stateless/Methods/Location.cs b/Shared/Models/Stateless/Methods/Location.cs index 2ee5801..b52f0d2 100644 --- a/Shared/Models/Stateless/Methods/Location.cs +++ b/Shared/Models/Stateless/Methods/Location.cs @@ -136,7 +136,10 @@ internal abstract class Location result = null; else { - if (!int.TryParse(segments[1], out int xWholePercent) || !int.TryParse(segments[2], out int yWholePercent) || !int.TryParse(segments[3], out int wWholePercent) || !int.TryParse(segments[4], out int hWholePercent)) + if (!int.TryParse(segments[1], out int xWholePercent) + || !int.TryParse(segments[2], out int yWholePercent) + || !int.TryParse(segments[3], out int wWholePercent) + || !int.TryParse(segments[4], out int hWholePercent)) result = null; else { diff --git a/Shared/Models/Stateless/Methods/XDirectory.cs b/Shared/Models/Stateless/Methods/XDirectory.cs index 580ac0f..94620ca 100644 --- a/Shared/Models/Stateless/Methods/XDirectory.cs +++ b/Shared/Models/Stateless/Methods/XDirectory.cs @@ -1,4 +1,5 @@ using System.Collections.ObjectModel; +using System.Diagnostics; namespace View_by_Distance.Shared.Models.Stateless.Methods; @@ -302,7 +303,7 @@ internal abstract partial class XDirectory internal static (string[], List<(FilePath, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, ReadOnlyCollection> filePathsCollection, ReadOnlyDictionary> fileGroups, ReadOnlyDictionary? exifDirectoriesById, Action? tick) { List<(FilePath, string)> results = []; - string paddedId; + string? paddedId; string checkFile; string directory; FilePath filePath; @@ -353,10 +354,7 @@ internal abstract partial class XDirectory { } } if (exifDirectoriesById is null || !exifDirectoriesById.TryGetValue(filePath.Id.Value, out exifDirectory)) - { - hasIgnoreKeyword = filePath.HasIgnoreKeyword; - hasDateTimeOriginal = filePath.HasDateTimeOriginal; - } + paddedId = IId.GetPaddedId(propertyConfiguration, filePath, i); else { dateTime = IDate.GetDateTimeOriginal(exifDirectory); @@ -365,8 +363,8 @@ internal abstract partial class XDirectory continue; keywords = MetaBase.GetKeywords(exifDirectory?.ExifBaseDirectories); hasIgnoreKeyword = propertyConfiguration.IgnoreRulesKeyWords.Any(keywords.Contains); + paddedId = IId.GetPaddedId(propertyConfiguration, filePath, hasIgnoreKeyword, hasDateTimeOriginal, i); } - paddedId = IId.GetPaddedId(propertyConfiguration, filePath.Id.Value, filePath.ExtensionLowered, hasIgnoreKeyword, hasDateTimeOriginal, i); paddedIdFile = Path.Combine(filePath.DirectoryFullPath, $"{paddedId}{filePath.ExtensionLowered}"); if (!File.Exists(paddedIdFile)) { @@ -384,15 +382,20 @@ internal abstract partial class XDirectory else { if (filePath.Id is null) - throw new NullReferenceException(nameof(filePath.Id)); - intelligentId = IId.GetIntelligentId(propertyConfiguration, filePath.Id.Value, filePath.ExtensionLowered, filePath.HasIgnoreKeyword, filePath.HasDateTimeOriginal); + { + if (Debugger.IsAttached) + continue; + else + throw new NullReferenceException(nameof(filePath.Id)); + } + intelligentId = IId.GetIntelligentId(propertyConfiguration, filePath); if (!isOffsetDeterministicHashCode) checkFile = Path.Combine(directory, $"{intelligentId}{filePath.ExtensionLowered}"); else { if (filePath.DirectoryFullPath is null) continue; - paddedId = IId.GetPaddedId(propertyConfiguration, filePath.Id.Value, filePath.ExtensionLowered, filePath.HasIgnoreKeyword, filePath.HasDateTimeOriginal, i); + paddedId = IId.GetPaddedId(propertyConfiguration, filePath, i); paddedIdFile = Path.Combine(filePath.DirectoryFullPath, $"{paddedId}{filePath.ExtensionLowered}"); if (File.Exists(paddedIdFile)) continue; diff --git a/Shared/Models/Stateless/Methods/XPath.cs b/Shared/Models/Stateless/Methods/XPath.cs index e875cf9..cb43d49 100644 --- a/Shared/Models/Stateless/Methods/XPath.cs +++ b/Shared/Models/Stateless/Methods/XPath.cs @@ -233,20 +233,6 @@ internal abstract class XPath } } - internal static void CreateDirectories(ReadOnlyCollection directories) - { - string checkDirectory; - foreach (string directory in directories) - { - for (int i = 0; i < 101; i++) - { - checkDirectory = Path.Combine(directory, i.ToString("000")); - if (!Directory.Exists(checkDirectory)) - _ = Directory.CreateDirectory(checkDirectory); - } - } - } - internal static void ChangeDateForEmptyDirectories(string rootDirectory, long ticks) { DateTime dateTime = new(ticks); diff --git a/Tests/UnitTestCalculations.cs b/Tests/UnitTestCalculations.cs index 53d0212..9735f47 100644 --- a/Tests/UnitTestCalculations.cs +++ b/Tests/UnitTestCalculations.cs @@ -162,8 +162,8 @@ public partial class UnitTestCalculations width = 100; height = 100; Location location = new(bottom, confidence, left, right, top); - _ = new Location(confidence, height, location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, 1); - _ = new Location(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1); + _ = new Location(confidence, height, location, width, 1); + _ = new Location(bottom, confidence, height, left, right, top, width, 1); NonThrowTryCatch(); } @@ -188,7 +188,7 @@ public partial class UnitTestCalculations bottom = 50; width = 100; height = 100; - location = new(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1); + location = new(bottom, confidence, height, left, right, top, width, 1); areaPermyriad = IMapping.GetAreaPermyriad(faceAreaPermyriad, height, location, width); Assert.IsTrue(areaPermyriad == 2500); left = 0; @@ -197,7 +197,7 @@ public partial class UnitTestCalculations bottom = 25; width = 100; height = 100; - location = new(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1); + location = new(bottom, confidence, height, left, right, top, width, 1); OutputResolution outputResolution = new(height, 0, width); areaPermyriad = IMapping.GetAreaPermyriad(faceAreaPermyriad, location, outputResolution); Assert.IsTrue(areaPermyriad == 625); diff --git a/Tests/UnitTestHardCoded.cs b/Tests/UnitTestHardCoded.cs index d4de3dc..5e61411 100644 --- a/Tests/UnitTestHardCoded.cs +++ b/Tests/UnitTestHardCoded.cs @@ -59,46 +59,46 @@ public partial class UnitTestHardCoded { int id; id = 748161839; - string imageTrueTruePositive = IId.GetPaddedId(_PropertyConfiguration, id, ".jpg", hasIgnoreKeyword: true, hasDateTimeOriginal: true, index: null); + string? imageTrueTruePositive = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".jpg", hasIgnoreKeyword: true, hasDateTimeOriginal: true, index: null); Assert.AreEqual("816184700398", imageTrueTruePositive); - string imageTrueFalsePositive = IId.GetPaddedId(_PropertyConfiguration, id, ".jpg", hasIgnoreKeyword: true, hasDateTimeOriginal: false, index: null); + string? imageTrueFalsePositive = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".jpg", hasIgnoreKeyword: true, hasDateTimeOriginal: false, index: null); Assert.AreEqual("816184700398", imageTrueFalsePositive); - string imageFalseFalsePositive = IId.GetPaddedId(_PropertyConfiguration, id, ".jpg", hasIgnoreKeyword: false, hasDateTimeOriginal: false, index: null); + string? imageFalseFalsePositive = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".jpg", hasIgnoreKeyword: false, hasDateTimeOriginal: false, index: null); Assert.AreEqual("816184700397", imageFalseFalsePositive); - string imageFalseTruePositive = IId.GetPaddedId(_PropertyConfiguration, id, ".jpg", hasIgnoreKeyword: false, hasDateTimeOriginal: true, index: null); + string? imageFalseTruePositive = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".jpg", hasIgnoreKeyword: false, hasDateTimeOriginal: true, index: null); Assert.AreEqual("816184700399", imageFalseTruePositive); try - { string videoTrueTruePositive = IId.GetPaddedId(_PropertyConfiguration, id, ".mov", hasIgnoreKeyword: true, hasDateTimeOriginal: true, index: null); } + { string? videoTrueTruePositive = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".mov", hasIgnoreKeyword: true, hasDateTimeOriginal: true, index: null); } catch (Exception) { } try - { string videoTrueFalsePositive = IId.GetPaddedId(_PropertyConfiguration, id, ".mov", hasIgnoreKeyword: true, hasDateTimeOriginal: false, index: null); } + { string? videoTrueFalsePositive = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".mov", hasIgnoreKeyword: true, hasDateTimeOriginal: false, index: null); } catch (Exception) { } - string videoFalseFalsePositive = IId.GetPaddedId(_PropertyConfiguration, id, ".mov", hasIgnoreKeyword: false, hasDateTimeOriginal: false, index: null); + string? videoFalseFalsePositive = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".mov", hasIgnoreKeyword: false, hasDateTimeOriginal: false, index: null); Assert.AreEqual("816184700395", videoFalseFalsePositive); - string videoFalseTruePositive = IId.GetPaddedId(_PropertyConfiguration, id, ".mov", hasIgnoreKeyword: false, hasDateTimeOriginal: true, index: null); + string? videoFalseTruePositive = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".mov", hasIgnoreKeyword: false, hasDateTimeOriginal: true, index: null); Assert.AreEqual("816184700396", videoFalseTruePositive); id = -748161839; - string imageTrueTrueNegative = IId.GetPaddedId(_PropertyConfiguration, id, ".jpg", hasIgnoreKeyword: true, hasDateTimeOriginal: true, index: null); + string? imageTrueTrueNegative = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".jpg", hasIgnoreKeyword: true, hasDateTimeOriginal: true, index: null); Assert.AreEqual("816184700392", imageTrueTrueNegative); - string imageTrueFalseNegative = IId.GetPaddedId(_PropertyConfiguration, id, ".jpg", hasIgnoreKeyword: true, hasDateTimeOriginal: false, index: null); + string? imageTrueFalseNegative = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".jpg", hasIgnoreKeyword: true, hasDateTimeOriginal: false, index: null); Assert.AreEqual("816184700392", imageTrueFalseNegative); - string imageFalseFalseNegative = IId.GetPaddedId(_PropertyConfiguration, id, ".jpg", hasIgnoreKeyword: false, hasDateTimeOriginal: false, index: null); + string? imageFalseFalseNegative = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".jpg", hasIgnoreKeyword: false, hasDateTimeOriginal: false, index: null); Assert.AreEqual("816184700393", imageFalseFalseNegative); - string imageFalseTrueNegative = IId.GetPaddedId(_PropertyConfiguration, id, ".jpg", hasIgnoreKeyword: false, hasDateTimeOriginal: true, index: null); + string? imageFalseTrueNegative = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".jpg", hasIgnoreKeyword: false, hasDateTimeOriginal: true, index: null); Assert.AreEqual("816184700391", imageFalseTrueNegative); try - { string videoTrueTrueNegative = IId.GetPaddedId(_PropertyConfiguration, id, ".mov", hasIgnoreKeyword: true, hasDateTimeOriginal: true, index: null); } + { string? videoTrueTrueNegative = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".mov", hasIgnoreKeyword: true, hasDateTimeOriginal: true, index: null); } catch (Exception) { } try - { string videoTrueFalseNegative = IId.GetPaddedId(_PropertyConfiguration, id, ".mov", hasIgnoreKeyword: true, hasDateTimeOriginal: false, index: null); } + { string? videoTrueFalseNegative = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".mov", hasIgnoreKeyword: true, hasDateTimeOriginal: false, index: null); } catch (Exception) { } - string videoFalseFalseNegative = IId.GetPaddedId(_PropertyConfiguration, id, ".mov", hasIgnoreKeyword: false, hasDateTimeOriginal: false, index: null); + string? videoFalseFalseNegative = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".mov", hasIgnoreKeyword: false, hasDateTimeOriginal: false, index: null); Assert.AreEqual("816184700390", videoFalseFalseNegative); - string videoFalseTrueNegative = IId.GetPaddedId(_PropertyConfiguration, id, ".mov", hasIgnoreKeyword: false, hasDateTimeOriginal: true, index: null); + string? videoFalseTrueNegative = IId.GetPaddedId(_PropertyConfiguration, id, string.Empty, ".mov", hasIgnoreKeyword: false, hasDateTimeOriginal: true, index: null); Assert.AreEqual("816184700394", videoFalseTrueNegative); NonThrowTryCatch(); } diff --git a/Tests/UnitTestResize.cs b/Tests/UnitTestResize.cs index 2f762d5..07309a1 100644 --- a/Tests/UnitTestResize.cs +++ b/Tests/UnitTestResize.cs @@ -87,26 +87,21 @@ public class UnitTestResize string sourceFileName = "105131603001106320328.jpg"; string sourceDirectoryName = "Mike iCloud Have Date Taken 2022 !9"; Item item; - bool reverse = false; bool isArchive = false; FileHolder resizedFileHolder; long ticks = DateTime.Now.Ticks; List parseExceptions = []; + string[] changesFrom = [nameof(A_Metadata)]; const bool isValidImageFormatExtension = true; List> subFileTuples = []; int length = _PropertyConfiguration.RootDirectory.Length; - string[] changesFrom = [nameof(A_Property)]; string outputResolution = _Configuration.OutputResolutions[0]; + string aResultsFullGroupDirectory = GetResultsFullGroupDirectories(); bool outputResolutionHasNumber = outputResolution.Any(char.IsNumber); (string cResultsFullGroupDirectory, _, _) = GetResultsFullGroupDirectories(outputResolution); - (string aResultsFullGroupDirectory, string bResultsFullGroupDirectory) = GetResultsFullGroupDirectories(); Shared.Models.Methods.IBlurHasher blurHasher = new BlurHash.Models.C2_BlurHasher(_PropertyConfiguration); - A_Property propertyLogic = GetPropertyLogic(reverse, aResultsFullGroupDirectory); - string aPropertySingletonDirectory = Path.Combine(aResultsFullGroupDirectory, "{}"); - if (!Directory.Exists(aPropertySingletonDirectory)) - _ = Directory.CreateDirectory(aPropertySingletonDirectory); (ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetTuple(_Configuration.OutputExtension, _Configuration.OutputQuality); - B_Metadata metadata = new(null, _PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, ticks, bResultsFullGroupDirectory); + A_Metadata metadata = new(null, _PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, ticks, aResultsFullGroupDirectory); _ = metadata.ToString(); C_Resize resize = new(_PropertyConfiguration, _Configuration.ForceResizeLastWriteTimeToCreationTime, _Configuration.OverrideForResizeImages, _Configuration.PropertiesChangedForResize, _Configuration.ValidResolutions, imageCodecInfo, encoderParameters, filenameExtension); _ = resize.ToString(); @@ -119,8 +114,6 @@ public class UnitTestResize Assert.IsNotNull(filePath.Id); string relativePath = IPath.GetRelativePath(fileHolder.FullName, length); ExifDirectory? exifDirectory = Metadata.Models.Stateless.Methods.IMetadata.GetExifDirectory(filePath); - string propertyLogicSourceDirectory = Path.GetFullPath(Path.Combine(aPropertySingletonDirectory, sourceDirectoryName)); - propertyLogic.SetAngleBracketCollection(aResultsFullGroupDirectory, propertyLogicSourceDirectory); if (outputResolutionHasNumber) resize.SetAngleBracketCollection(cResultsFullGroupDirectory, sourceDirectory); resize.Update(cResultsFullGroupDirectory); @@ -144,23 +137,16 @@ public class UnitTestResize NonThrowTryCatch(); } - private (string, string) GetResultsFullGroupDirectories() + private string GetResultsFullGroupDirectories() { - string aResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory( - _PropertyConfiguration, - nameof(A_Property), + string result = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory( + _Configuration.PropertyConfiguration, + nameof(A_Metadata), string.Empty, includeResizeGroup: false, includeModel: false, includePredictorModel: false); - string bResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory( - _PropertyConfiguration, - nameof(B_Metadata), - string.Empty, - includeResizeGroup: false, - includeModel: false, - includePredictorModel: false); - return new(aResultsFullGroupDirectory, bResultsFullGroupDirectory); + return new(result); } private (string, string, string) GetResultsFullGroupDirectories(string outputResolution) @@ -177,13 +163,4 @@ public class UnitTestResize return new(cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory); } - private A_Property GetPropertyLogic(bool reverse, string aResultsFullGroupDirectory) - { - A_Property result; - if (_Configuration?.PropertyConfiguration is null) - throw new NullReferenceException(nameof(_PropertyConfiguration)); - result = new(_AppSettings.MaxDegreeOfParallelism, _PropertyConfiguration, _Configuration.OutputExtension, reverse, aResultsFullGroupDirectory); - return result; - } - } \ No newline at end of file diff --git a/TestsWithFaceRecognitionDotNet/UnitTestFace.cs b/TestsWithFaceRecognitionDotNet/UnitTestFace.cs index dc468c7..156118a 100644 --- a/TestsWithFaceRecognitionDotNet/UnitTestFace.cs +++ b/TestsWithFaceRecognitionDotNet/UnitTestFace.cs @@ -68,26 +68,21 @@ public class UnitTestFace string sourceFileName = "100000507001158650387.jpg"; string sourceDirectoryName = "Facebook/2023.2 Summer Facebook"; Item item; - bool reverse = false; bool isArchive = false; FileHolder resizedFileHolder; long ticks = DateTime.Now.Ticks; List parseExceptions = []; + string[] changesFrom = [nameof(A_Metadata)]; const bool isValidImageFormatExtension = true; List> subFileTuples = []; int length = _PropertyConfiguration.RootDirectory.Length; - string[] changesFrom = [nameof(A_Property)]; string outputResolution = _Configuration.OutputResolutions[0]; + string aResultsFullGroupDirectory = GetResultsFullGroupDirectories(); bool outputResolutionHasNumber = outputResolution.Any(char.IsNumber); (string cResultsFullGroupDirectory, _, _) = GetResultsFullGroupDirectories(outputResolution); - (string aResultsFullGroupDirectory, string bResultsFullGroupDirectory) = GetResultsFullGroupDirectories(); Shared.Models.Methods.IBlurHasher blurHasher = new BlurHash.Models.C2_BlurHasher(_PropertyConfiguration); - A_Property propertyLogic = GetPropertyLogic(reverse, aResultsFullGroupDirectory); - string aPropertySingletonDirectory = Path.Combine(aResultsFullGroupDirectory, "{}"); - if (!Directory.Exists(aPropertySingletonDirectory)) - _ = Directory.CreateDirectory(aPropertySingletonDirectory); (ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetTuple(_Configuration.OutputExtension, _Configuration.OutputQuality); - B_Metadata metadata = new(null, _PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, ticks, bResultsFullGroupDirectory); + A_Metadata metadata = new(null, _PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, ticks, aResultsFullGroupDirectory); _ = metadata.ToString(); C_Resize resize = new(_PropertyConfiguration, _Configuration.ForceResizeLastWriteTimeToCreationTime, _Configuration.OverrideForResizeImages, _Configuration.PropertiesChangedForResize, _Configuration.ValidResolutions, imageCodecInfo, encoderParameters, filenameExtension); _ = resize.ToString(); @@ -100,8 +95,6 @@ public class UnitTestFace Assert.IsNotNull(filePath.Id); string relativePath = IPath.GetRelativePath(fileHolder.FullName, length); ExifDirectory? exifDirectory = Metadata.Models.Stateless.Methods.IMetadata.GetExifDirectory(filePath); - string propertyLogicSourceDirectory = Path.GetFullPath(Path.Combine(aPropertySingletonDirectory, sourceDirectoryName)); - propertyLogic.SetAngleBracketCollection(aResultsFullGroupDirectory, propertyLogicSourceDirectory); if (outputResolutionHasNumber) resize.SetAngleBracketCollection(cResultsFullGroupDirectory, sourceDirectory); resize.Update(cResultsFullGroupDirectory); @@ -134,23 +127,16 @@ public class UnitTestFace NonThrowTryCatch(); } - private (string, string) GetResultsFullGroupDirectories() + private string GetResultsFullGroupDirectories() { - string aResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory( - _PropertyConfiguration, - nameof(A_Property), + string result = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory( + _Configuration.PropertyConfiguration, + nameof(A_Metadata), string.Empty, includeResizeGroup: false, includeModel: false, includePredictorModel: false); - string bResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory( - _PropertyConfiguration, - nameof(B_Metadata), - string.Empty, - includeResizeGroup: false, - includeModel: false, - includePredictorModel: false); - return new(aResultsFullGroupDirectory, bResultsFullGroupDirectory); + return new(result); } private (string, string, string) GetResultsFullGroupDirectories(string outputResolution) @@ -167,15 +153,6 @@ public class UnitTestFace return new(cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory); } - private A_Property GetPropertyLogic(bool reverse, string aResultsFullGroupDirectory) - { - A_Property result; - if (_Configuration?.PropertyConfiguration is null) - throw new NullReferenceException(nameof(_PropertyConfiguration)); - result = new(_AppSettings.MaxDegreeOfParallelism, _PropertyConfiguration, _Configuration.OutputExtension, reverse, aResultsFullGroupDirectory); - return result; - } - private static (Model model, PredictorModel predictorModel, ModelParameter modelParameter) GetModel(Models.Configuration configuration) { (Model, PredictorModel, ModelParameter) result;