Tests project and Resize bug

This commit is contained in:
Mike Phares 2022-07-27 21:05:56 -07:00
parent 36592ea319
commit f642c5669a
30 changed files with 1838 additions and 478 deletions

View File

@ -1,5 +1,6 @@
{
"cSpell.words": [
"appsettings",
"ASPNETCORE",
"Barrick",
"bcdfghjklmnpqrstvwxyz",

View File

@ -79,7 +79,7 @@
"/zzz Phares Slides/Slides 2015-06-10/Magazine 01"
],
"Configuration": {
"DateGroup": "2022-07-24",
"DateGroup": "2022-07-27",
"DiffPropertyDirectory": "",
"FileNameDirectorySeparator": ".Z.",
"ForcePropertyLastWriteTimeToCreationTime": false,
@ -87,20 +87,20 @@
"Pattern": "[^ABCDEFGHIJKLMNOPQRSTUVWXYZbcdfghjklmnpqrstvwxyz0-9]",
"PopulatePropertyId": true,
"PropertiesChangedForProperty": false,
"RootDirectory": "C:/Tmp/Phares/Compare/Images 2022-07-24 - 1539b2f974f07b6b5cbda8450faf0eec85d02eda - III",
"RootDirectory": "C:/Tmp/Phares/Compare/Images 2022-07-27 - 20220727 - III",
"WriteBitmapDataBytes": false,
"IgnoreExtensions": [
".gif",
".GIF"
],
"PropertyContentCollectionFiles": [
"/Images 2022-07-24 - 1539b2f974f07b6b5cbda8450faf0eec85d02eda - III - Results/A) Property/2022-07-24/[()]/637869381676042455.json",
"/Not-Copy-Copy/Images 2019-06-08 - 34a9240ac28b52da97428d7725153a80a757ee6b - Not-Copy-Copy - Results/A) Property/2022-07-24/[()]/637869733124119330.json",
"/Not-Copy-Copy/Images 2018-12-25 - 34a9240ac28b52da97428d7725153a80a757ee6b - Not-Copy-Copy - Results/A) Property/2022-07-24/[()]/637869734240700328.json",
"/Not-Copy-Copy/Images 2018-05-12 - b01d4763d8853b6d6057a3870b2723449726da75 - Not-Copy-Copy - Results/A) Property/2022-07-24/[()]/637869734970730630.json",
"/Not-Copy-Copy/Images 2013-12-15 - d02c8791fa0b130c0bce2d39ee684e50f7ee7a97 - Not-Copy-Copy - Results/A) Property/2022-07-24/[()]/637869743752078399.json",
"/Not-Copy-Copy - Delta/Amazon Drive - Results/A) Property/2022-07-24/[()]/637869744751177715.json",
"/Not-Copy-Copy - Delta/Blackberry - Results/A) Property/2022-07-24/[()]/637869745134124462.json"
"/Images 2022-07-27 - 20220727 - III - Results/A) Property/2022-07-27/[()]/637869381676042455.json",
"/Not-Copy-Copy/Images 2019-06-08 - 34a9240ac28b52da97428d7725153a80a757ee6b - Not-Copy-Copy - Results/A) Property/2022-07-27/[()]/637869733124119330.json",
"/Not-Copy-Copy/Images 2018-12-25 - 34a9240ac28b52da97428d7725153a80a757ee6b - Not-Copy-Copy - Results/A) Property/2022-07-27/[()]/637869734240700328.json",
"/Not-Copy-Copy/Images 2018-05-12 - b01d4763d8853b6d6057a3870b2723449726da75 - Not-Copy-Copy - Results/A) Property/2022-07-27/[()]/637869734970730630.json",
"/Not-Copy-Copy/Images 2013-12-15 - d02c8791fa0b130c0bce2d39ee684e50f7ee7a97 - Not-Copy-Copy - Results/A) Property/2022-07-27/[()]/637869743752078399.json",
"/Not-Copy-Copy - Delta/Amazon Drive - Results/A) Property/2022-07-27/[()]/637869744751177715.json",
"/Not-Copy-Copy - Delta/Blackberry - Results/A) Property/2022-07-27/[()]/637869745134124462.json"
],
"ValidImageFormatExtensions": [
".bmp",

View File

@ -50,7 +50,7 @@
"WorkingDirectoryName": "PharesApps",
"Windows": {
"Configuration": {
"DateGroup": "2022-07-24",
"DateGroup": "2022-07-27",
"DiffPropertyDirectory": "",
"FileNameDirectorySeparator": ".Z.",
"ForcePropertyLastWriteTimeToCreationTime": false,
@ -94,13 +94,13 @@
".GIF"
],
"PropertyContentCollectionFiles": [
"/Images 2022-07-24 - 1539b2f974f07b6b5cbda8450faf0eec85d02eda - III - Results/A) Property/2022-07-24/[()]/637869381676042455.json",
"/Not-Copy-Copy/Images 2019-06-08 - 34a9240ac28b52da97428d7725153a80a757ee6b - Not-Copy-Copy - Results/A) Property/2022-07-24/[()]/637869733124119330.json",
"/Not-Copy-Copy/Images 2018-12-25 - 34a9240ac28b52da97428d7725153a80a757ee6b - Not-Copy-Copy - Results/A) Property/2022-07-24/[()]/637869734240700328.json",
"/Not-Copy-Copy/Images 2018-05-12 - b01d4763d8853b6d6057a3870b2723449726da75 - Not-Copy-Copy - Results/A) Property/2022-07-24/[()]/637869734970730630.json",
"/Not-Copy-Copy/Images 2013-12-15 - d02c8791fa0b130c0bce2d39ee684e50f7ee7a97 - Not-Copy-Copy - Results/A) Property/2022-07-24/[()]/637869743752078399.json",
"/Not-Copy-Copy - Delta/Amazon Drive - Results/A) Property/2022-07-24/[()]/637869744751177715.json",
"/Not-Copy-Copy - Delta/Blackberry - Results/A) Property/2022-07-24/[()]/637869745134124462.json"
"/Images 2022-07-27 - 20220727 - III - Results/A) Property/2022-07-27/[()]/637869381676042455.json",
"/Not-Copy-Copy/Images 2019-06-08 - 34a9240ac28b52da97428d7725153a80a757ee6b - Not-Copy-Copy - Results/A) Property/2022-07-27/[()]/637869733124119330.json",
"/Not-Copy-Copy/Images 2018-12-25 - 34a9240ac28b52da97428d7725153a80a757ee6b - Not-Copy-Copy - Results/A) Property/2022-07-27/[()]/637869734240700328.json",
"/Not-Copy-Copy/Images 2018-05-12 - b01d4763d8853b6d6057a3870b2723449726da75 - Not-Copy-Copy - Results/A) Property/2022-07-27/[()]/637869734970730630.json",
"/Not-Copy-Copy/Images 2013-12-15 - d02c8791fa0b130c0bce2d39ee684e50f7ee7a97 - Not-Copy-Copy - Results/A) Property/2022-07-27/[()]/637869743752078399.json",
"/Not-Copy-Copy - Delta/Amazon Drive - Results/A) Property/2022-07-27/[()]/637869744751177715.json",
"/Not-Copy-Copy - Delta/Blackberry - Results/A) Property/2022-07-27/[()]/637869745134124462.json"
],
"ValidImageFormatExtensions": [
".bmp",

View File

@ -55,7 +55,7 @@
"ByHash": false,
"BySeason": false,
"ByWeek": false,
"DateGroup": "2022-07-24",
"DateGroup": "2022-07-27",
"FileNameDirectorySeparator": ".Z.",
"ForcePropertyLastWriteTimeToCreationTime": false,
"KeepFullPath": false,
@ -63,7 +63,7 @@
"Pattern": "[^ABCDEFGHIJKLMNOPQRSTUVWXYZbcdfghjklmnpqrstvwxyz0-9]",
"PopulatePropertyId": true,
"PropertiesChangedForProperty": false,
"RootDirectory": "C:/Tmp/Phares/Compare/Images 2022-07-24 - 1539b2f974f07b6b5cbda8450faf0eec85d02eda - III",
"RootDirectory": "C:/Tmp/Phares/Compare/Images 2022-07-27 - 20220727 - III",
"WriteBitmapDataBytes": false,
"IgnoreExtensions": [
".gif",

View File

@ -299,8 +299,8 @@ public class DlibDotNet
private void FullParallelForWork(PropertyLogic propertyLogic, object @lock, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileInfo?> propertyFileInfoCollection, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollections, List<Dictionary<string, int[]>> resizeKeyValuePairs, List<List<D_Face>> imageFaceCollections, string sourceDirectory, int index, PropertyHolder propertyHolder)
{
if (propertyHolder.FileInfo is null)
throw new Exception($"{nameof(propertyHolder.FileInfo)} is null!");
if (propertyHolder.ImageFileInfo is null)
throw new Exception($"{nameof(propertyHolder.ImageFileInfo)} is null!");
if (_AppSettings.MaxDegreeOfParallelism is null)
throw new Exception($"{nameof(_AppSettings.MaxDegreeOfParallelism)} is null!");
if (_Configuration.SaveResizedSubfiles is null)
@ -320,34 +320,34 @@ public class DlibDotNet
List<KeyValuePair<string, string>> metadataCollection;
if (propertyHolder.Property is null)
{
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), propertyHolder.FileInfo.LastWriteTime));
property = propertyLogic.GetProperty(propertyLogic.AngleBracketCollection[0], sourceDirectory, propertyHolder.FileInfo.FullName, subFileTuples, parseExceptions, propertyHolder.FileInfo);
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), propertyHolder.ImageFileInfo.LastWriteTime));
property = propertyLogic.GetProperty(propertyLogic.AngleBracketCollection[0], propertyHolder, subFileTuples, parseExceptions);
}
else
{
property = propertyHolder.Property;
if (propertyHolder.Changed.HasValue && propertyHolder.Changed.Value)
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), propertyHolder.FileInfo.LastWriteTime));
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), propertyHolder.ImageFileInfo.LastWriteTime));
}
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(propertyHolder.FileInfo.FullName);
(int metadataGroups, metadataCollection) = _Metadata.GetMetadataCollection(subFileTuples, parseExceptions, propertyHolder.FileInfo.FullName, propertyHolder.RelativePath, fileNameWithoutExtension);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(propertyHolder.ImageFileInfo.FullName);
(int metadataGroups, metadataCollection) = _Metadata.GetMetadataCollection(subFileTuples, parseExceptions, propertyHolder.ImageFileInfo.FullName, propertyHolder.RelativePath, fileNameWithoutExtension);
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
ticks = LogDelta(ticks, nameof(B_Metadata.GetMetadataCollection));
FileInfo resizedFileInfo = new(Path.Combine(_Resize.AngleBracketCollection[0].Replace("<>", "()"), Path.GetFileName(propertyHolder.FileInfo.FullName)));
FileInfo resizedFileInfo = new(Path.Combine(_Resize.AngleBracketCollection[0].Replace("<>", "()"), Path.GetFileName(propertyHolder.ImageFileInfo.FullName)));
propertyHolder.SetResizedFileInfo(resizedFileInfo);
imageResizeKeyValuePairs = _Resize.GetResizeKeyValuePairs(subFileTuples, parseExceptions, original, metadataCollection, property, propertyHolder.FileInfo.FullName, propertyHolder.RelativePath, fileNameWithoutExtension);
imageResizeKeyValuePairs = _Resize.GetResizeKeyValuePairs(subFileTuples, parseExceptions, original, metadataCollection, property, propertyHolder.ImageFileInfo.FullName, propertyHolder.RelativePath, fileNameWithoutExtension);
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
ticks = LogDelta(ticks, nameof(C_Resize.GetResizeKeyValuePairs));
if (_Configuration.SaveResizedSubfiles.Value)
{
_Resize.SaveResizedSubfile(outputResolution, subFileTuples, propertyHolder.FileInfo.FullName, original, property, imageResizeKeyValuePairs, resizedFileInfo);
_Resize.SaveResizedSubfile(outputResolution, subFileTuples, propertyHolder.ImageFileInfo.FullName, original, property, imageResizeKeyValuePairs, resizedFileInfo);
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
ticks = LogDelta(ticks, nameof(C_Resize.SaveResizedSubfile));
resizedFileInfo.Refresh();
}
else if (outputResolution == _Configuration.OutputResolutions[0] && false)
{
byte[] bytes = _Resize.GetResizedBytes(outputResolution, subFileTuples, propertyHolder.FileInfo.FullName, property, imageResizeKeyValuePairs);
byte[] bytes = _Resize.GetResizedBytes(outputResolution, subFileTuples, propertyHolder.ImageFileInfo.FullName, property, imageResizeKeyValuePairs);
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
ticks = LogDelta(ticks, nameof(C_Resize.GetResizedBytes));
string path = Path.Combine(resizedFileInfo.DirectoryName, Path.GetFileNameWithoutExtension(resizedFileInfo.Name));
@ -380,7 +380,7 @@ public class DlibDotNet
imageFaceCollections[index] = faceCollection;
metadataCollections[index] = metadataCollection;
resizeKeyValuePairs[index] = imageResizeKeyValuePairs;
propertyFileInfoCollection[index] = propertyHolder.FileInfo;
propertyFileInfoCollection[index] = propertyHolder.ImageFileInfo;
sourceDirectoryChanges.AddRange(from l in subFileTuples where l.Item2 > dateTime select l);
}
}
@ -495,9 +495,9 @@ public class DlibDotNet
propertyHolder = filteredPropertyHolderCollection[i];
if (propertyHolder.Property is null)
continue;
if (propertyHolder.FileInfo is null)
if (propertyHolder.ImageFileInfo is null)
continue;
key = Property.Models.Stateless.IPath.GetRelativePath(propertyHolder.FileInfo.FullName, sourceDirectoryLength);
key = Property.Models.Stateless.IPath.GetRelativePath(propertyHolder.ImageFileInfo.FullName, sourceDirectoryLength);
_FileKeyValuePairs.Add(new KeyValuePair<string, string>(sourceDirectory, key));
_FilePropertiesKeyValuePairs[sourceDirectory].Add(new Tuple<string, A_Property>(key, propertyCollection[i]));
faceCollectionsKeyValuePairs.Add(new KeyValuePair<string, List<D_Face>>(key, faceCollections[i]));
@ -587,7 +587,7 @@ public class DlibDotNet
continue;
if (!_ArgZeroIsConfigurationRootDirectory && !propertyHolderCollection[0].SourceDirectory.StartsWith(argZero))
continue;
filteredPropertyHolderCollection = (from l in propertyHolderCollection where l.FileInfo is not null && l.Property is not null && l.ValidImageFormatExtension.HasValue && l.ValidImageFormatExtension.Value && !_Configuration.IgnoreExtensions.Contains(l.FileInfo.Extension) select l).ToArray();
filteredPropertyHolderCollection = (from l in propertyHolderCollection where l.ImageFileInfo is not null && l.Property is not null && l.ValidImageFormatExtension.HasValue && l.ValidImageFormatExtension.Value && !_Configuration.IgnoreExtensions.Contains(l.ImageFileInfo.Extension) select l).ToArray();
if (!filteredPropertyHolderCollection.Any())
continue;
faceCollections.Clear();

View File

@ -524,9 +524,9 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
personKey = string.Empty;
copyDirectory = string.Empty;
propertyHolder = filteredPropertyHolderCollection[i];
if (propertyHolder.FileInfo is null)
if (propertyHolder.ImageFileInfo is null)
continue;
fileInfo = propertyHolder.FileInfo;
fileInfo = propertyHolder.ImageFileInfo;
relativePath = Path.GetDirectoryName($"C:{propertyHolder.RelativePath}");
if (string.IsNullOrEmpty(relativePath) || relativePath.Length < 3)
continue;

View File

@ -184,7 +184,7 @@ internal class E_Distance
throw new Exception();
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
{
fileInfo = filteredPropertyHolderCollection[i].FileInfo;
fileInfo = filteredPropertyHolderCollection[i].ImageFileInfo;
if (fileInfo is null)
continue;
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
@ -223,7 +223,7 @@ internal class E_Distance
collectionDescription: "n json file(s) for each face found (one to many)");
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
{
fileInfo = filteredPropertyHolderCollection[i].FileInfo;
fileInfo = filteredPropertyHolderCollection[i].ImageFileInfo;
if (fileInfo is null)
continue;
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);

View File

@ -9,7 +9,7 @@
"Microsoft.Hosting.Lifetime": "Information"
}
},
"MaxDegreeOfParallelism": 1,
"MaxDegreeOfParallelism": 6,
"Serilog": {
"Using": [
"Serilog.Sinks.Console",
@ -52,7 +52,7 @@
"Configuration": {
"CheckJsonForDistanceResults": true,
"CrossDirectoryMaxItemsInDistanceCollection": 7,
"DateGroup": "2022-07-24",
"DateGroup": "2022-07-27",
"DistanceFactor": 8,
"FileNameDirectorySeparator": ".Z.",
"ForceMetadataLastWriteTimeToCreationTime": false,
@ -86,7 +86,7 @@
"PropertiesChangedForResize": false,
"Reverse": false,
"xRootDirectory": "C:/Tmp/phares/Pictures",
"RootDirectory": "F:/Tmp/Phares/Compare/Images 2022-07-24 - 1539b2f974f07b6b5cbda8450faf0eec85d02eda - III",
"RootDirectory": "F:/Tmp/Phares/Compare/Images 2022-07-27 - 20220727 - III",
"SaveFullYearOfRandomFiles": true,
"SaveResizedSubFiles": true,
"SaveShortcuts": true,
@ -162,7 +162,7 @@
"1024 x 768"
],
"OutputResolutions": [
"1376 x 768"
"1920 x 1080"
],
"PropertyContentCollectionFiles": [],
"SaveFaceLandmarkForOutputResolutions": [

View File

@ -52,7 +52,7 @@
"Configuration": {
"CheckJsonForDistanceResults": true,
"CrossDirectoryMaxItemsInDistanceCollection": 7,
"DateGroup": "2022-07-24",
"DateGroup": "2022-07-27",
"DistanceFactor": 8,
"FileNameDirectorySeparator": ".Z.",
"ForceMetadataLastWriteTimeToCreationTime": false,

View File

@ -52,7 +52,7 @@
"Configuration": {
"CheckJsonForDistanceResults": true,
"CrossDirectoryMaxItemsInDistanceCollection": 7,
"DateGroup": "2022-07-24",
"DateGroup": "2022-07-27",
"DistanceFactor": 8,
"FileNameDirectorySeparator": ".Z.",
"ForceMetadataLastWriteTimeToCreationTime": false,

View File

@ -111,6 +111,8 @@ public class B_Metadata
dictionary = new();
else if (!fileInfo.Exists)
dictionary = new();
else if (!fileInfo.FullName.EndsWith(".json") && !fileInfo.FullName.EndsWith(".old"))
throw new ArgumentException("must be a *.json file");
else if (dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
dictionary = new();
else

View File

@ -50,7 +50,7 @@
"WorkingDirectoryName": "PharesApps",
"Windows": {
"Configuration": {
"DateGroup": "2022-07-24",
"DateGroup": "2022-07-27",
"FileNameDirectorySeparator": ".Z.",
"ForcePropertyLastWriteTimeToCreationTime": false,
"MaxImagesInDirectoryForTopLevelFirstPass": 50,

View File

@ -50,7 +50,7 @@
"WorkingDirectoryName": "PharesApps",
"Windows": {
"Configuration": {
"DateGroup": "2022-07-24",
"DateGroup": "2022-07-27",
"FileNameDirectorySeparator": ".Z.",
"ForcePropertyLastWriteTimeToCreationTime": false,
"KeepFullPath": false,

View File

@ -7,7 +7,7 @@ public class PropertyHolder
protected readonly bool? _Abandoned;
protected readonly bool? _Changed;
protected FileInfo? _FileInfo;
protected FileInfo? _ImageFileInfo;
protected readonly int _G;
protected DateTime? _MinimumDateTime;
protected bool? _Moved;
@ -22,7 +22,7 @@ public class PropertyHolder
protected bool? _WrongYear;
public bool? Abandoned => _Abandoned;
public bool? Changed => _Changed;
public FileInfo? FileInfo => _FileInfo;
public FileInfo? ImageFileInfo => _ImageFileInfo;
public int G => _G;
public DateTime? MinimumDateTime => _MinimumDateTime;
public bool? Moved => _Moved;
@ -46,11 +46,11 @@ public class PropertyHolder
}
[JsonConstructor]
public PropertyHolder(int g, string sourceDirectory, string sourceDirectoryFile, string relativePath, int r, FileInfo? fileInfo, A_Property? property, bool? abandoned, bool? changed, bool? moved, bool? validImageFormatExtension, bool? wrongYear)
public PropertyHolder(int g, string sourceDirectory, string sourceDirectoryFile, string relativePath, int r, FileInfo? imageFileInfo, A_Property? property, bool? abandoned, bool? changed, bool? moved, bool? validImageFormatExtension, bool? wrongYear)
{
_Abandoned = abandoned;
_Changed = changed;
_FileInfo = fileInfo;
_ImageFileInfo = imageFileInfo;
_G = g;
_Moved = moved;
_NoJson = abandoned is null;
@ -62,6 +62,10 @@ public class PropertyHolder
_ValidImageFormatExtension = validImageFormatExtension;
_WrongYear = wrongYear;
_MinimumDateTime = Stateless.A_Property.GetMinimumDateTime(property);
if (imageFileInfo is not null && imageFileInfo.Extension is ".json")
throw new ArgumentException("Can not be a *.json file!");
if (!sourceDirectoryFile.EndsWith(".json") && !sourceDirectoryFile.EndsWith(".old"))
throw new ArgumentException("Must be a *.json or *.old file!");
}
internal void SetValidImageFormatExtension(bool isValidImageFormatExtension) => _ValidImageFormatExtension = isValidImageFormatExtension;
@ -72,11 +76,7 @@ public class PropertyHolder
public void SetResizedFileInfo(FileInfo fileInfo) => _ResizedFileInfo = fileInfo;
internal void Update(FileInfo fileInfo, A_Property property)
{
_Property = property;
_FileInfo = fileInfo;
}
internal void Update(A_Property property) => _Property = property;
public bool Any() => (_Abandoned.HasValue && _Abandoned.Value) || (_Changed.HasValue && _Changed.Value) || (_Moved.HasValue && _Moved.Value) || (_NoJson.HasValue && _NoJson.Value);

View File

@ -148,171 +148,7 @@ public class PropertyLogic
#pragma warning disable CA1416
private A_Property GetImageProperty(string angleBracket, string filteredSourceDirectoryFile, bool populateId, bool isIgnoreExtension, bool isValidImageFormatExtension, bool isValidMetadataExtensions, int? id, List<int> indices, long fileInfoLength, DateTime creationTime, DateTime lastWriteTime)
{
A_Property result;
if (_Log is null)
throw new Exception($"{nameof(_Log)} is null!");
if (_Configuration.WriteBitmapDataBytes is null)
throw new Exception($"{nameof(_Configuration.WriteBitmapDataBytes)} is null!");
long ticks;
byte[] bytes;
string value;
int encodingHash;
int? width = null;
int? height = null;
string dateTimeFormat;
DateTime checkDateTime;
DateTime? dateTime = null;
PropertyItem? propertyItem;
string make = string.Empty;
string model = string.Empty;
DateTime? gpsDateStamp = null;
DateTime? dateTimeOriginal = null;
string orientation = string.Empty;
DateTime? dateTimeDigitized = null;
if (!isValidImageFormatExtension && isValidMetadataExtensions)
{
dateTimeFormat = "ddd MMM dd HH:mm:ss yyyy";
List<DateTime> dateTimes = GetMetadataDateTimesByPattern(dateTimeFormat, filteredSourceDirectoryFile);
if (dateTimes.Any())
dateTimeOriginal = dateTimes.Min();
}
else if (!isIgnoreExtension && isValidImageFormatExtension)
{
try
{
using Image image = Image.FromFile(filteredSourceDirectoryFile);
if (populateId && (id is null || !indices.Any()))
{
using Bitmap bitmap = new(image);
Rectangle rectangle = new(0, 0, image.Width, image.Height);
BitmapData bitmapData = bitmap.LockBits(rectangle, ImageLockMode.ReadOnly, bitmap.PixelFormat);
IntPtr intPtr = bitmapData.Scan0;
int length = bitmapData.Stride * bitmap.Height;
bytes = new byte[length];
Marshal.Copy(intPtr, bytes, 0, length);
bitmap.UnlockBits(bitmapData);
if (id is null)
{
ticks = DateTime.Now.Ticks;
id = Stateless.A_Property.GetDeterministicHashCode(bytes);
if (_MaxDegreeOfParallelism < 2)
ticks = LogDelta(ticks, nameof(Stateless.A_Property.GetDeterministicHashCode));
}
if (_Configuration.WriteBitmapDataBytes.Value)
{
FileInfo contentFileInfo = new(Path.Combine(angleBracket.Replace("<>", "()"), Path.GetFileName(filteredSourceDirectoryFile)));
File.WriteAllBytes(Path.ChangeExtension(contentFileInfo.FullName, string.Empty), bytes);
}
if (_IndicesFromNew.ContainsKey(id.Value) && _IndicesFromNew[id.Value].Any())
indices.AddRange(_IndicesFromNew[id.Value]);
else
{
ticks = DateTime.Now.Ticks;
string encoding = Encoding.Default.GetString(bytes);
if (_MaxDegreeOfParallelism < 2)
ticks = LogDelta(ticks, nameof(Encoding.Default.GetString));
encodingHash = Stateless.A_Property.GetDeterministicHashCode(encoding);
if (_MaxDegreeOfParallelism < 2)
ticks = LogDelta(ticks, nameof(Stateless.A_Property.GetDeterministicHashCode));
if (!_IndicesFromOld.ContainsKey(encodingHash))
indices.Add(encodingHash);
else
indices.AddRange(_IndicesFromOld[encodingHash]);
}
}
width = image.Width;
height = image.Height;
dateTimeFormat = Stateless.A_Property.DateTimeFormat();
if (image.PropertyIdList.Contains((int)IExif.Tags.DateTime))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.DateTime);
if (propertyItem?.Value is not null)
{
value = _ASCIIEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
if (value.Length > dateTimeFormat.Length)
value = value[..dateTimeFormat.Length];
if (value.Length == dateTimeFormat.Length && DateTime.TryParseExact(value, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out checkDateTime))
dateTime = checkDateTime;
}
}
if (image.PropertyIdList.Contains((int)IExif.Tags.DateTimeDigitized))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.DateTimeDigitized);
if (propertyItem?.Value is not null)
{
value = _ASCIIEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
if (value.Length > dateTimeFormat.Length)
value = value[..dateTimeFormat.Length];
if (value.Length == dateTimeFormat.Length && DateTime.TryParseExact(value, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out checkDateTime))
dateTimeDigitized = checkDateTime;
}
}
if (image.PropertyIdList.Contains((int)IExif.Tags.DateTimeOriginal))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.DateTimeOriginal);
if (propertyItem?.Value is not null)
{
value = _ASCIIEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
if (value.Length > dateTimeFormat.Length)
value = value[..dateTimeFormat.Length];
if (value.Length == dateTimeFormat.Length && DateTime.TryParseExact(value, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out checkDateTime))
dateTimeOriginal = checkDateTime;
}
}
if (image.PropertyIdList.Contains((int)IExif.Tags.GPSDateStamp))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.GPSDateStamp);
if (propertyItem?.Value is not null)
{
value = _ASCIIEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
if (value.Length > dateTimeFormat.Length)
value = value[..dateTimeFormat.Length];
if (value.Length == dateTimeFormat.Length && DateTime.TryParseExact(value, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out checkDateTime))
gpsDateStamp = checkDateTime;
}
}
if (image.PropertyIdList.Contains((int)IExif.Tags.Make))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.Make);
if (propertyItem?.Value is not null)
{
value = _ASCIIEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
make = value;
}
}
if (image.PropertyIdList.Contains((int)IExif.Tags.Model))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.Model);
if (propertyItem?.Value is not null)
{
value = _ASCIIEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
model = value;
}
}
if (image.PropertyIdList.Contains((int)IExif.Tags.Orientation))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.Orientation);
if (propertyItem?.Value is not null)
{
value = BitConverter.ToInt16(propertyItem.Value, 0).ToString();
orientation = value;
}
}
}
catch (Exception)
{
_Log.Info(string.Concat(new StackFrame().GetMethod()?.Name, " <", filteredSourceDirectoryFile, ">"));
}
}
else
dateTimeOriginal = null;
result = new(creationTime, dateTime, dateTimeDigitized, dateTimeOriginal, fileInfoLength, gpsDateStamp, height, id, indices.ToArray(), lastWriteTime, make, model, orientation, width);
return result;
}
private A_Property GetImagePropertyB(string angleBracket, FileInfo filteredSourceDirectoryFileInfo, bool populateId, bool isIgnoreExtension, bool isValidImageFormatExtension, bool isValidMetadataExtensions, int? id, List<int> indices)
private A_Property GetImageProperty(string angleBracket, FileInfo filteredSourceDirectoryFileInfo, bool populateId, bool isIgnoreExtension, bool isValidImageFormatExtension, bool isValidMetadataExtensions, int? id, List<int> indices)
{
A_Property result;
if (_Log is null)
@ -478,7 +314,7 @@ public class PropertyLogic
#pragma warning restore CA1416
private A_Property GetPropertyA(List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples, List<string> parseExceptions, bool firstPass, string angleBracket, FileInfo filteredSourceDirectoryFileInfo, FileInfo fileInfo, bool isIgnoreExtension, bool isValidImageFormatExtension, bool isValidMetadataExtensions)
private A_Property GetPropertyOfPrivate(string angleBracket, PropertyHolder propertyHolder, bool firstPass, List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples, List<string> parseExceptions, bool isIgnoreExtension, bool isValidImageFormatExtension, bool isValidMetadataExtensions, string extensionLowered, string fileNameWithoutExtension)
{
A_Property? result;
if (_Configuration.ForcePropertyLastWriteTimeToCreationTime is null)
@ -493,6 +329,13 @@ public class PropertyLogic
bool hasWrongYearProperty = false;
string[] changesFrom = Array.Empty<string>();
bool populateId = !firstPass && _Configuration.PopulatePropertyId.Value;
string without = Path.Combine(angleBracket.Replace("<>", "{}"), $"{fileNameWithoutExtension}.json");
FileInfo fileInfo = new(Path.Combine(angleBracket.Replace("<>", "{}"), $"{fileNameWithoutExtension}{extensionLowered}.json"));
if (isValidImageFormatExtension && File.Exists(without))
{
File.Move(without, fileInfo.FullName);
fileInfo.Refresh();
}
List<DateTime> dateTimes = (from l in filteredSourceDirectoryFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
if (!fileInfo.Exists)
{
@ -519,6 +362,8 @@ public class PropertyLogic
result = null;
else if (!fileInfo.Exists)
result = null;
else if (!fileInfo.FullName.EndsWith(".json") && !fileInfo.FullName.EndsWith(".old"))
throw new ArgumentException("must be a *.json file");
else if (dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
result = null;
else
@ -526,6 +371,8 @@ public class PropertyLogic
json = File.ReadAllText(fileInfo.FullName);
try
{
if (propertyHolder.ImageFileInfo is null)
throw new ArgumentException($"{propertyHolder.ImageFileInfo} is null!");
bool check = true;
A_Property? property = JsonSerializer.Deserialize<A_Property>(json);
if (!isIgnoreExtension && isValidImageFormatExtension && ((populateId && property?.Id is null) || property?.Width is null || property?.Height is null))
@ -534,7 +381,7 @@ public class PropertyLogic
id = property?.Id;
if (property is not null && property.Indices.Any())
indices = property.Indices.ToList();
property = GetImagePropertyB(angleBracket, filteredSourceDirectoryFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
property = GetImageProperty(angleBracket, propertyHolder.ImageFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
}
if (!isIgnoreExtension && isValidImageFormatExtension && populateId && property is not null && !property.Indices.Any())
{
@ -542,22 +389,22 @@ public class PropertyLogic
id = property?.Id;
if (property is not null && property.Indices.Any())
indices = property.Indices.ToList();
property = GetImagePropertyB(angleBracket, filteredSourceDirectoryFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
property = GetImageProperty(angleBracket, propertyHolder.ImageFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
}
if (!isIgnoreExtension && isValidImageFormatExtension && populateId && property is not null && property.LastWriteTime != filteredSourceDirectoryFileInfo.LastWriteTime)
if (!isIgnoreExtension && isValidImageFormatExtension && populateId && property is not null && property.LastWriteTime != propertyHolder.ImageFileInfo.LastWriteTime)
{
check = false;
id = null;
indices.Clear();
property = GetImagePropertyB(angleBracket, filteredSourceDirectoryFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
property = GetImageProperty(angleBracket, propertyHolder.ImageFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
}
if (!isIgnoreExtension && isValidImageFormatExtension && property?.Width is not null && property?.Height is not null && property.Width.Value == property.Height.Value && filteredSourceDirectoryFileInfo.Exists)
if (!isIgnoreExtension && isValidImageFormatExtension && property?.Width is not null && property?.Height is not null && property.Width.Value == property.Height.Value && propertyHolder.ImageFileInfo.Exists)
{
check = false;
id = property?.Id;
if (property is not null && property.Indices.Any())
indices = property.Indices.ToList();
property = GetImagePropertyB(angleBracket, filteredSourceDirectoryFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
property = GetImageProperty(angleBracket, propertyHolder.ImageFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
if (property?.Width is not null && property?.Height is not null && property.Width.Value != property.Height.Value)
throw new Exception("Was square!");
}
@ -591,145 +438,9 @@ public class PropertyLogic
}
if (result is null)
{
result = GetImagePropertyB(angleBracket, filteredSourceDirectoryFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
json = JsonSerializer.Serialize(result, _WriteIndentedJsonSerializerOptions);
if (populateId && IPath.WriteAllText(fileInfo.FullName, json, compareBeforeWrite: true))
{
if (!_Configuration.ForcePropertyLastWriteTimeToCreationTime.Value && (!fileInfo.Exists || fileInfo.LastWriteTime == fileInfo.CreationTime))
filteredSourceDirectoryFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), DateTime.Now));
else
{
File.SetLastWriteTime(fileInfo.FullName, fileInfo.CreationTime);
fileInfo.Refresh();
filteredSourceDirectoryFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), fileInfo.CreationTime));
}
}
}
else if (hasWrongYearProperty)
{
json = JsonSerializer.Serialize(result, _WriteIndentedJsonSerializerOptions);
if (IPath.WriteAllText(fileInfo.FullName, json, compareBeforeWrite: true))
{
File.SetLastWriteTime(fileInfo.FullName, fileInfo.CreationTime);
fileInfo.Refresh();
filteredSourceDirectoryFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), fileInfo.CreationTime));
}
}
return result;
}
private A_Property GetPropertyB(List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples, List<string> parseExceptions, bool firstPass, string angleBracket, FileInfo filteredSourceDirectoryFileInfo, A_Property? property, FileInfo fileInfo, bool isIgnoreExtension, bool isValidImageFormatExtension, bool isValidMetadataExtensions)
{
A_Property? result;
if (_Configuration.ForcePropertyLastWriteTimeToCreationTime is null)
throw new Exception($"{nameof(_Configuration.ForcePropertyLastWriteTimeToCreationTime)} is null!");
if (_Configuration.PopulatePropertyId is null)
throw new Exception($"{nameof(_Configuration.PopulatePropertyId)} is null!");
if (_Configuration.PropertiesChangedForProperty is null)
throw new Exception($"{nameof(_Configuration.PropertiesChangedForProperty)} is null!");
string json;
int? id = null;
List<int> indices = new();
bool hasWrongYearProperty = false;
string[] changesFrom = Array.Empty<string>();
bool populateId = !firstPass && _Configuration.PopulatePropertyId.Value;
List<DateTime> dateTimes = (from l in filteredSourceDirectoryFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
if (!fileInfo.Exists)
{
if (fileInfo.Directory?.Parent is null)
throw new Exception();
string parentCheck = Path.Combine(fileInfo.Directory.Parent.FullName, fileInfo.Name);
if (File.Exists(parentCheck))
{
File.Move(parentCheck, fileInfo.FullName);
fileInfo.Refresh();
}
}
if (_Configuration.ForcePropertyLastWriteTimeToCreationTime.Value && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
{
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
fileInfo.Refresh();
}
if (_Configuration.ForcePropertyLastWriteTimeToCreationTime.Value && fileInfo.Exists && fileInfo.LastWriteTime != fileInfo.CreationTime)
{
File.SetLastWriteTime(fileInfo.FullName, fileInfo.CreationTime);
fileInfo.Refresh();
}
if (_Configuration.PropertiesChangedForProperty.Value)
result = null;
else if (!fileInfo.Exists)
result = null;
else
{
json = File.ReadAllText(fileInfo.FullName);
try
{
bool check = true;
property = JsonSerializer.Deserialize<A_Property>(json);
if (!isIgnoreExtension && isValidImageFormatExtension && ((populateId && property?.Id is null) || property?.Width is null || property?.Height is null))
{
check = false;
id = property?.Id;
if (property is not null && property.Indices.Any())
indices = property.Indices.ToList();
property = GetImagePropertyB(angleBracket, filteredSourceDirectoryFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
}
if (!isIgnoreExtension && isValidImageFormatExtension && populateId && property is not null && !property.Indices.Any())
{
check = false;
id = property?.Id;
if (property is not null && property.Indices.Any())
indices = property.Indices.ToList();
property = GetImagePropertyB(angleBracket, filteredSourceDirectoryFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
}
if (!isIgnoreExtension && isValidImageFormatExtension && populateId && property is not null && property.LastWriteTime != filteredSourceDirectoryFileInfo.LastWriteTime)
{
check = false;
id = null;
indices.Clear();
property = GetImagePropertyB(angleBracket, filteredSourceDirectoryFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
}
if (!isIgnoreExtension && isValidImageFormatExtension && property?.Width is not null && property?.Height is not null && property.Width.Value == property.Height.Value && filteredSourceDirectoryFileInfo.Exists)
{
check = false;
id = property?.Id;
if (property is not null && property.Indices.Any())
indices = property.Indices.ToList();
property = GetImagePropertyB(angleBracket, filteredSourceDirectoryFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
if (property?.Width is not null && property?.Height is not null && property.Width.Value != property.Height.Value)
throw new Exception("Was square!");
}
// if (filteredSourceDirectoryFileFileInfo.CreationTime != property?.CreationTime || filteredSourceDirectoryFileFileInfo.LastWriteTime != property?.LastWriteTime)
// {
// check = false;
// id = null;
// indices.Clear();
// property = GetImagePropertyB(angleBracket, filteredSourceDirectoryFile, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
// }
if (json.Contains("WrongYear"))
{
id = property?.Id;
hasWrongYearProperty = true;
}
if (property is null)
throw new Exception();
if (!check)
result = null;
else
{
result = property;
filteredSourceDirectoryFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), fileInfo.LastWriteTime));
}
}
catch (Exception)
{
result = null;
parseExceptions.Add(nameof(A_Property));
}
}
if (result is null)
{
result = GetImagePropertyB(angleBracket, filteredSourceDirectoryFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
if (propertyHolder.ImageFileInfo is null)
throw new ArgumentException($"{propertyHolder.ImageFileInfo} is null!");
result = GetImageProperty(angleBracket, propertyHolder.ImageFileInfo, populateId, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, id, indices);
json = JsonSerializer.Serialize(result, _WriteIndentedJsonSerializerOptions);
if (populateId && IPath.WriteAllText(fileInfo.FullName, json, compareBeforeWrite: true))
{
@ -778,14 +489,14 @@ public class PropertyLogic
continue;
if (propertyHolder.Property is null)
continue;
if (propertyHolder.FileInfo is null)
if (propertyHolder.ImageFileInfo is null)
continue;
minimumDateTime = Stateless.A_Property.GetMinimumDateTime(propertyHolder.Property);
if (minimumDateTime > directoryMaximumOfMinimumDateTime)
directoryMaximumOfMinimumDateTime = minimumDateTime;
if (minimumDateTime != propertyHolder.FileInfo.CreationTime)
if (minimumDateTime != propertyHolder.ImageFileInfo.CreationTime)
{
(isWrongYear, matches) = propertyHolder.Property.IsWrongYear(propertyHolder.FileInfo.FullName, minimumDateTime);
(isWrongYear, matches) = propertyHolder.Property.IsWrongYear(propertyHolder.ImageFileInfo.FullName, minimumDateTime);
if (isWrongYear is null || !isWrongYear.Value)
dateTime = minimumDateTime;
else
@ -801,18 +512,18 @@ public class PropertyLogic
continue;
}
try
{ File.SetCreationTime(propertyHolder.FileInfo.FullName, dateTime); }
{ File.SetCreationTime(propertyHolder.ImageFileInfo.FullName, dateTime); }
catch (Exception)
{ }
}
if (!_VerifyToSeason.Contains(sourceDirectory))
continue;
if (!propertyHolder.FileInfo.FullName.Contains("zzz ") && !propertyHolder.FileInfo.FullName.Contains("Camera ") && propertyHolder.Property.DateTimeOriginal.HasValue)
if (!propertyHolder.ImageFileInfo.FullName.Contains("zzz ") && !propertyHolder.ImageFileInfo.FullName.Contains("Camera ") && propertyHolder.Property.DateTimeOriginal.HasValue)
{
TimeSpan timeSpan = new(propertyHolder.Property.DateTimeOriginal.Value.Ticks - propertyHolder.Property.LastWriteTime.Ticks);
if (timeSpan.TotalHours > 6)
{
_Log.Warning($"*** propertyHolder.FileInfo.FullName <{propertyHolder.FileInfo.FullName}>");
_Log.Warning($"*** propertyHolder.FileInfo.FullName <{propertyHolder.ImageFileInfo.FullName}>");
_Log.Warning($"*** DateTimeOriginal <{propertyHolder.Property.DateTimeOriginal.Value}>");
_Log.Warning($"*** LastWriteTime <{propertyHolder.Property.LastWriteTime}>");
_Log.Warning($"*** TotalHours <{timeSpan.TotalHours}>");
@ -834,35 +545,35 @@ public class PropertyLogic
result = true;
if (!Directory.Exists(destinationDirectory))
_ = Directory.CreateDirectory(destinationDirectory);
destinationFile = Path.Combine(destinationDirectory, propertyHolder.FileInfo.Name);
destinationFile = Path.Combine(destinationDirectory, propertyHolder.ImageFileInfo.Name);
if (File.Exists(destinationFile))
{
if (destinationFile.EndsWith(".jpg", ignoreCase: true, CultureInfo.CurrentCulture))
destinationFile = Path.Combine(destinationDirectory, Path.ChangeExtension(propertyHolder.FileInfo.Name, ".jpeg"));
destinationFile = Path.Combine(destinationDirectory, Path.ChangeExtension(propertyHolder.ImageFileInfo.Name, ".jpeg"));
else if (destinationFile.EndsWith(".jpeg", ignoreCase: true, CultureInfo.CurrentCulture))
destinationFile = Path.Combine(destinationDirectory, Path.ChangeExtension(propertyHolder.FileInfo.Name, ".jpg"));
destinationFile = Path.Combine(destinationDirectory, Path.ChangeExtension(propertyHolder.ImageFileInfo.Name, ".jpg"));
}
if (File.Exists(destinationFile))
{
_Log.Information($"*** source <{propertyHolder.FileInfo.FullName}>");
_Log.Information($"*** source <{propertyHolder.ImageFileInfo.FullName}>");
_Log.Information($"*** destination <{destinationFile}>");
if (propertyHolder.FileInfo.Exists)
if (propertyHolder.ImageFileInfo.Exists)
{
deleteFile = Path.ChangeExtension(propertyHolder.FileInfo.FullName, ".delete");
deleteFile = Path.ChangeExtension(propertyHolder.ImageFileInfo.FullName, ".delete");
if (File.Exists(deleteFile))
File.Delete(deleteFile);
File.Move(propertyHolder.FileInfo.FullName, deleteFile);
File.Move(propertyHolder.ImageFileInfo.FullName, deleteFile);
}
}
else
{
File.Move(propertyHolder.FileInfo.FullName, destinationFile);
if (propertyHolder.FileInfo.Exists)
File.Move(propertyHolder.ImageFileInfo.FullName, destinationFile);
if (propertyHolder.ImageFileInfo.Exists)
{
deleteFile = Path.ChangeExtension(propertyHolder.FileInfo.FullName, ".delete");
deleteFile = Path.ChangeExtension(propertyHolder.ImageFileInfo.FullName, ".delete");
if (File.Exists(deleteFile))
File.Delete(deleteFile);
File.Move(propertyHolder.FileInfo.FullName, deleteFile);
File.Move(propertyHolder.ImageFileInfo.FullName, deleteFile);
}
}
}
@ -891,9 +602,9 @@ public class PropertyLogic
{
if (propertyHolder.Property is null)
continue;
if (propertyHolder.FileInfo is null)
if (propertyHolder.ImageFileInfo is null)
continue;
key = IPath.GetRelativePath(propertyHolder.FileInfo.FullName, sourceDirectoryLength);
key = IPath.GetRelativePath(propertyHolder.ImageFileInfo.FullName, sourceDirectoryLength);
propertyCollectionKeyValuePairs.Add(new KeyValuePair<string, A_Property>(key, propertyHolder.Property));
}
checkDirectory = IPath.GetDirectory(angleBracket, level, "[{}]");
@ -908,32 +619,25 @@ public class PropertyLogic
private void ParallelForWork(bool firstPass, string angleBracket, string sourceDirectory, List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples, PropertyHolder propertyHolder)
{
if (propertyHolder.FileInfo is null)
throw new Exception($"{nameof(propertyHolder.FileInfo)} is null!");
if (propertyHolder.ImageFileInfo is null)
throw new Exception($"{nameof(propertyHolder.ImageFileInfo)} is null!");
A_Property property;
List<string> parseExceptions = new();
string extensionLowered = propertyHolder.FileInfo.Extension.ToLower();
string extensionLowered = propertyHolder.ImageFileInfo.Extension.ToLower();
bool isValidMetadataExtensions = _Configuration.ValidMetadataExtensions.Contains(extensionLowered);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(propertyHolder.FileInfo.FullName);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(propertyHolder.ImageFileInfo.FullName);
bool isValidImageFormatExtension = _Configuration.ValidImageFormatExtensions.Contains(extensionLowered);
lock (propertyHolder)
propertyHolder.SetValidImageFormatExtension(isValidImageFormatExtension);
bool isIgnoreExtension = isValidImageFormatExtension && _Configuration.IgnoreExtensions.Contains(extensionLowered);
string filteredSourceDirectoryFileExtensionLowered = Path.Combine(sourceDirectory, $"{fileNameWithoutExtension}{extensionLowered}");
if (isValidImageFormatExtension && propertyHolder.FileInfo.FullName.Length == filteredSourceDirectoryFileExtensionLowered.Length && propertyHolder.FileInfo.FullName != filteredSourceDirectoryFileExtensionLowered)
File.Move(propertyHolder.FileInfo.FullName, filteredSourceDirectoryFileExtensionLowered);
if (isValidImageFormatExtension && propertyHolder.ImageFileInfo.FullName.Length == filteredSourceDirectoryFileExtensionLowered.Length && propertyHolder.ImageFileInfo.FullName != filteredSourceDirectoryFileExtensionLowered)
File.Move(propertyHolder.ImageFileInfo.FullName, filteredSourceDirectoryFileExtensionLowered);
if (propertyHolder.Changed is null || propertyHolder.Changed.Value || propertyHolder.Property is null)
{
string without = Path.Combine(angleBracket.Replace("<>", "{}"), $"{fileNameWithoutExtension}.json");
FileInfo fileInfo = new(Path.Combine(angleBracket.Replace("<>", "{}"), $"{fileNameWithoutExtension}{extensionLowered}.json"));
if (isValidImageFormatExtension && File.Exists(without))
{
File.Move(without, fileInfo.FullName);
fileInfo.Refresh();
}
property = GetPropertyB(filteredSourceDirectoryFileTuples, parseExceptions, firstPass, angleBracket, propertyHolder.FileInfo, propertyHolder.Property, fileInfo, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions);
property = GetPropertyOfPrivate(angleBracket, propertyHolder, firstPass, filteredSourceDirectoryFileTuples, parseExceptions, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, extensionLowered,fileNameWithoutExtension);
lock (propertyHolder)
propertyHolder.Update(fileInfo, property);
propertyHolder.Update(property);
}
}
@ -1010,7 +714,7 @@ public class PropertyLogic
if (firstPass)
filteredPropertyHolderCollection = (from l in propertyHolderCollection where l.NoJson is null || !l.NoJson.Value && (l.Changed is null || l.Changed.Value) select l).ToArray();
else
filteredPropertyHolderCollection = (from l in propertyHolderCollection where l.FileInfo is not null && !_Configuration.IgnoreExtensions.Contains(l.FileInfo.Extension) select l).ToArray();
filteredPropertyHolderCollection = (from l in propertyHolderCollection where l.ImageFileInfo is not null && !_Configuration.IgnoreExtensions.Contains(l.ImageFileInfo.Extension) select l).ToArray();
if (!filteredPropertyHolderCollection.Any())
continue;
g = filteredPropertyHolderCollection[0].G;
@ -1045,27 +749,18 @@ public class PropertyLogic
}
}
public A_Property GetProperty(string angleBracket, string sourceDirectory, string filteredSourceDirectoryFile, List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples, List<string> parseExceptions, FileInfo fileInfo)
public A_Property GetProperty(string angleBracket, PropertyHolder propertyHolder, List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples, List<string> parseExceptions)
{
A_Property result;
if (propertyHolder.ImageFileInfo is null)
throw new ArgumentException($"{propertyHolder.ImageFileInfo} is null!");
bool firstPass = false;
FileInfo filteredSourceDirectoryFileInfo = new(filteredSourceDirectoryFile);
string extensionLowered = filteredSourceDirectoryFileInfo.Extension.ToLower();
string extensionLowered = propertyHolder.ImageFileInfo.Extension.ToLower();
bool isValidMetadataExtensions = _Configuration.ValidMetadataExtensions.Contains(extensionLowered);
bool isValidImageFormatExtension = _Configuration.ValidImageFormatExtensions.Contains(extensionLowered);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filteredSourceDirectoryFileInfo.FullName);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(propertyHolder.ImageFileInfo.FullName);
bool isIgnoreExtension = isValidImageFormatExtension && _Configuration.IgnoreExtensions.Contains(extensionLowered);
string filteredSourceDirectoryFileExtensionLowered = Path.Combine(sourceDirectory, $"{fileNameWithoutExtension}{extensionLowered}");
if (isValidImageFormatExtension && filteredSourceDirectoryFile.Length == filteredSourceDirectoryFileExtensionLowered.Length && filteredSourceDirectoryFile != filteredSourceDirectoryFileExtensionLowered)
File.Move(filteredSourceDirectoryFile, filteredSourceDirectoryFileExtensionLowered);
string without = Path.Combine(angleBracket.Replace("<>", "{}"), $"{fileNameWithoutExtension}.json");
FileInfo propertyFileInfo = new(Path.Combine(angleBracket.Replace("<>", "{}"), $"{fileNameWithoutExtension}{extensionLowered}.json"));
if (isValidImageFormatExtension && File.Exists(without))
{
File.Move(without, propertyFileInfo.FullName);
propertyFileInfo.Refresh();
}
result = GetPropertyA(filteredSourceDirectoryFileTuples, parseExceptions, firstPass, angleBracket, filteredSourceDirectoryFileInfo, fileInfo, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions);
result = GetPropertyOfPrivate(angleBracket, propertyHolder, firstPass, filteredSourceDirectoryFileTuples, parseExceptions, isIgnoreExtension, isValidImageFormatExtension, isValidMetadataExtensions, extensionLowered, fileNameWithoutExtension);
return result;
}

View File

@ -169,6 +169,8 @@ public static class A_Property
{
inferred = string.Concat(configuration.RootDirectory, relativePath);
keyFileInfo = new(inferred[..^5]);
if (keyFileInfo.Extension is ".json")
continue;
keySourceDirectory = string.Concat(keyFileInfo.DirectoryName);
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, true, null, null, null, null));
}
@ -178,6 +180,8 @@ public static class A_Property
keySourceDirectory = fileInfoKeyValuePairs[relativePath].SourceDirectory;
if (!fileInfoKeyValuePairs.Remove(relativePath))
throw new Exception();
if (keyFileInfo.Extension is ".json")
continue;
if (property?.Id is null || property?.Width is null || property?.Height is null)
propertyHolderCollection.Add(new(g, keySourceDirectory, sourceDirectoryFile, relativePath, r, keyFileInfo, property, false, null, null, null, null));
else if (configuration.PropertiesChangedForProperty.Value || property.LastWriteTime != keyFileInfo.LastWriteTime || property.FileSize != keyFileInfo.Length)
@ -200,6 +204,8 @@ public static class A_Property
continue;
if (!fileInfoKeyValuePairs.Remove(relativePath))
throw new Exception();
if (sourceDirectoryFileInfo.Extension is ".json")
continue;
propertyHolderCollection.Add(new(g, sourceDirectory, relativePath, sourceDirectoryFileInfo.FullName, r, sourceDirectoryFileInfo, null, null, null, null, null, null));
}
if (propertyHolderCollection.Any())

View File

@ -20,21 +20,31 @@ public class C_Resize
public List<string> AngleBracketCollection { get; }
private readonly Serilog.ILogger? _Log;
private readonly int _TempResolutionWidth;
private readonly int _TempResolutionHeight;
private readonly string[] _ValidResolutions;
private readonly ASCIIEncoding _ASCIIEncoding;
private readonly bool _OverrideForResizeImages;
private readonly ImageCodecInfo _ImageCodecInfo;
private readonly ConstructorInfo _ConstructorInfo;
private readonly int _OutputResolutionWidthIndex;
private readonly bool _PropertiesChangedForResize;
private readonly ConstructorInfo _ConstructorInfo;
private readonly int _OutputResolutionHeightIndex;
private readonly EncoderParameters _EncoderParameters;
private readonly int _OutputResolutionOrientationIndex;
private readonly bool _ForceResizeLastWriteTimeToCreationTime;
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
public C_Resize(bool forceResizeLastWriteTimeToCreationTime, bool overrideForResizeImages, bool propertiesChangedForResize, string[] validResolutions, ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters)
{
_TempResolutionWidth = 3;
_TempResolutionHeight = 4;
_OutputResolutionWidthIndex = 0;
_ImageCodecInfo = imageCodecInfo;
_OutputResolutionHeightIndex = 1;
_ASCIIEncoding = new ASCIIEncoding();
_ValidResolutions = validResolutions;
_OutputResolutionOrientationIndex = 2;
_EncoderParameters = encoderParameters;
_Log = Serilog.Log.ForContext<C_Resize>();
AngleBracketCollection = new List<string>();
@ -93,10 +103,19 @@ public class C_Resize
{
bool hasId = false;
int id = (int)IExif.Tags.DateTimeDigitized;
int imageWidth = (int)IExif.Tags.ImageWidth;
int imageLength = (int)IExif.Tags.ImageLength;
int orientation = (int)IExif.Tags.Orientation;
foreach (PropertyItem propertyItem in propertyItems)
{
if (propertyItem.Id == id)
hasId = true;
else if (propertyItem.Id == imageWidth)
continue;
else if (propertyItem.Id == imageLength)
continue;
else if (propertyItem.Id == orientation)
continue;
bitmap.SetPropertyItem(propertyItem);
}
if (!hasId)
@ -114,11 +133,11 @@ public class C_Resize
{
byte[] results;
Bitmap bitmap;
int outputResolutionWidth = resize[0];
int outputResolutionHeight = resize[1];
int outputResolutionOrientation = resize[2];
int outputResolutionWidth = resize[_OutputResolutionWidthIndex];
using Bitmap temp = new(subFile, useIcm: false);
int outputResolutionHeight = resize[_OutputResolutionHeightIndex];
PropertyItem[] propertyItems = temp.PropertyItems;
int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex];
bitmap = new(temp, outputResolutionWidth, outputResolutionHeight);
switch (outputResolutionOrientation) // exif 274
{
@ -166,13 +185,13 @@ public class C_Resize
{
byte[] results;
Bitmap bitmap;
int tempResolutionWidth = resize[3];
int tempResolutionHeight = resize[4];
int outputResolutionWidth = resize[0];
int outputResolutionHeight = resize[1];
int outputResolutionOrientation = resize[2];
using Bitmap temp = new(subFile, useIcm: false);
PropertyItem[] propertyItems = temp.PropertyItems;
int tempResolutionWidth = resize[_TempResolutionWidth];
int tempResolutionHeight = resize[_TempResolutionHeight];
int outputResolutionWidth = resize[_OutputResolutionWidthIndex];
int outputResolutionHeight = resize[_OutputResolutionHeightIndex];
int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex];
bitmap = new(temp, tempResolutionWidth, tempResolutionHeight);
switch (outputResolutionOrientation) // exif 274
{
@ -271,9 +290,9 @@ public class C_Resize
if (!imageResizes.ContainsKey(outputResolution))
throw new Exception();
int[] resize = imageResizes[outputResolution];
int outputResolutionWidth = resize[0];
int outputResolutionHeight = resize[1];
int outputResolutionOrientation = resize[2];
int outputResolutionWidth = resize[_OutputResolutionWidthIndex];
int outputResolutionHeight = resize[_OutputResolutionHeightIndex];
int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex];
results = SaveResizedSubfile(subFile, property, resize, fileInfo: null);
subFileTuples.Add(new Tuple<string, DateTime>(nameof(C_Resize), DateTime.Now));
return results;
@ -295,11 +314,11 @@ public class C_Resize
}
}
int[] resize = imageResizes[outputResolution];
int outputResolutionWidth = resize[0];
int outputResolutionHeight = resize[1];
int outputResolutionOrientation = resize[2];
int outputResolutionWidth = resize[_OutputResolutionWidthIndex];
int outputResolutionHeight = resize[_OutputResolutionHeightIndex];
int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex];
int[] originalCollection = imageResizes[original];
if (outputResolutionWidth == originalCollection[0] && outputResolutionHeight == originalCollection[1] && outputResolutionOrientation == originalCollection[2])
if (outputResolutionWidth == originalCollection[_OutputResolutionWidthIndex] && outputResolutionHeight == originalCollection[_OutputResolutionHeightIndex] && outputResolutionOrientation == originalCollection[_OutputResolutionOrientationIndex])
{
if (!fileInfo.Exists)
{
@ -349,7 +368,7 @@ public class C_Resize
return result;
}
private Dictionary<string, int[]> GetImageResizes(List<KeyValuePair<string, string>> metadataCollection, A_Property property, string original)
private Dictionary<string, int[]> GetImageResizes(A_Property property, List<KeyValuePair<string, string>> metadataCollection, string original)
{
Dictionary<string, int[]> results = new();
int[] desired;
@ -364,49 +383,8 @@ public class C_Resize
orientation = propertyOrientation;
else
orientation = GetOrientation(metadataCollection);
switch (orientation) // exif 274
{
case 0:
checkWidth = property.Width.Value;
checkHeight = property.Height.Value;
break;
case 1:
checkWidth = property.Width.Value;
checkHeight = property.Height.Value;
break; // 1 = Horizontal (normal)
case 2:
checkWidth = property.Width.Value;
checkHeight = property.Height.Value;
break; // 2 = Mirror horizontal
case 3:
checkWidth = property.Width.Value;
checkHeight = property.Height.Value;
break; // 3 = Rotate 180
case 4:
checkWidth = property.Width.Value;
checkHeight = property.Height.Value;
break; // 4 = Mirror vertical
case 5:
checkWidth = property.Height.Value;
checkHeight = property.Width.Value;
break; // 5 = Mirror horizontal and rotate 270 CW
case 6:
checkWidth = property.Height.Value;
checkHeight = property.Width.Value;
break; // 6 = Rotate 90 CW
case 7:
checkWidth = property.Height.Value;
checkHeight = property.Width.Value;
break; // 7 = Mirror horizontal and rotate 90 CW
case 8:
checkWidth = property.Height.Value;
checkHeight = property.Width.Value;
break; // 8 = Rotate 270 CW
default:
checkWidth = property.Width.Value;
checkHeight = property.Height.Value;
break;
}
checkWidth = property.Width.Value;
checkHeight = property.Height.Value;
results.Add(original, new int[] { checkWidth, checkHeight, orientation });
foreach (string validResolution in _ValidResolutions)
{
@ -468,6 +446,8 @@ public class C_Resize
results = new();
else if (!fileInfo.Exists)
results = new();
else if (!fileInfo.FullName.EndsWith(".json") && !fileInfo.FullName.EndsWith(".old"))
throw new ArgumentException("must be a *.json file");
else if (dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
results = new();
else
@ -482,7 +462,7 @@ public class C_Resize
results = keyValuePairs;
if ((from l in results where l.Value[0] == l.Value[1] select true).Any())
{
results = GetImageResizes(metadataCollection, property, original);
results = GetImageResizes(property, metadataCollection, original);
if (!(from l in results where l.Value[0] == l.Value[1] select true).Any())
throw new Exception("Was square!");
}
@ -496,7 +476,7 @@ public class C_Resize
}
if (results is null || !results.Any())
{
results = GetImageResizes(metadataCollection, property, original);
results = GetImageResizes(property, metadataCollection, original);
json = JsonSerializer.Serialize(results, _WriteIndentedJsonSerializerOptions);
if (Property.Models.Stateless.IPath.WriteAllText(fileInfo.FullName, json, compareBeforeWrite: true))
{

View File

@ -0,0 +1,35 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Tests.Models;
public class AppSettings
{
protected string _Company;
protected string _WorkingDirectoryName;
protected int? _MaxDegreeOfParallelism;
public string Company => _Company;
public string WorkingDirectoryName => _WorkingDirectoryName;
public int? MaxDegreeOfParallelism => _MaxDegreeOfParallelism;
// public AppSettings()
// {
// }
[JsonConstructor]
public AppSettings(string company, string workingDirectoryName, int? maxDegreeOfParallelism)
{
_Company = company;
_WorkingDirectoryName = workingDirectoryName;
_MaxDegreeOfParallelism = maxDegreeOfParallelism;
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
}

View File

@ -0,0 +1,26 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json;
namespace View_by_Distance.Tests.Models.Binder;
public class AppSettings
{
[Display(Name = "Company"), Required] public string Company { get; set; }
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
[Display(Name = "Max Degree Of Parallelism"), Required] public int? MaxDegreeOfParallelism { get; set; }
public AppSettings()
{
Company = string.Empty;
WorkingDirectoryName = string.Empty;
MaxDegreeOfParallelism = -1;
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
}

View File

@ -0,0 +1,101 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json;
namespace View_by_Distance.Tests.Models.Binder;
public class Configuration
{
[Display(Name = "Check Json For Distance Results"), Required] public bool? CheckJsonForDistanceResults { get; set; }
[Display(Name = "CrossDirectory Max Items In Distance Collection"), Required] public int? CrossDirectoryMaxItemsInDistanceCollection { get; set; }
[Display(Name = "Distance Factor"), Required] public int? DistanceFactor { get; set; }
[Display(Name = "Force Metadata Last Write Time to Creation Time"), Required] public bool? ForceMetadataLastWriteTimeToCreationTime { get; set; }
[Display(Name = "Force Resize Last Write Time to Creation Time"), Required] public bool? ForceResizeLastWriteTimeToCreationTime { get; set; }
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
[Display(Name = "Ignore Relative Paths"), Required] public string[] IgnoreRelativePaths { get; set; }
[Display(Name = "Julie Phares Copy Birthdays"), Required] public string[] JuliePhares { get; set; }
[Display(Name = "Load Or Create Then Save Directory Distance Results"), Required] public bool? LoadOrCreateThenSaveDirectoryDistanceResults { get; set; }
[Display(Name = "Load Or Create Then Save Distance Results"), Required] public bool? LoadOrCreateThenSaveDistanceResults { get; set; }
[Display(Name = "Load Or Create Then Save Image Faces Results"), Required] public bool? LoadOrCreateThenSaveImageFacesResults { get; set; }
[Display(Name = "Load Or Create Then Save Index"), Required] public bool? LoadOrCreateThenSaveIndex { get; set; }
[Display(Name = "Location Confidence Factor"), Required] public int? LocationConfidenceFactor { get; set; }
[Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; }
[Display(Name = "Max Items In Distance Collection"), Required] public int? MaxItemsInDistanceCollection { get; set; }
[Display(Name = "Mixed Year Relative Paths"), Required] public string[] MixedYearRelativePaths { get; set; }
[Display(Name = "Model Directory"), Required] public string ModelDirectory { get; set; }
[Display(Name = "Model Name"), Required] public string ModelName { get; set; }
[Display(Name = "Num Jitters"), Required] public int? NumJitters { get; set; }
[Display(Name = "Output Extension"), Required] public string OutputExtension { get; set; }
[Display(Name = "Output Quality"), Required] public int? OutputQuality { get; set; }
[Display(Name = "Output Resolutions"), Required] public string[] OutputResolutions { get; set; }
[Display(Name = "Override For Face Images"), Required] public bool? OverrideForFaceImages { get; set; }
[Display(Name = "Override For Face Landmark Images"), Required] public bool? OverrideForFaceLandmarkImages { get; set; }
[Display(Name = "Override For Resize Images"), Required] public bool? OverrideForResizeImages { get; set; }
[Display(Name = "Padding Loops"), Required] public int? PaddingLoops { get; set; }
[Display(Name = "Predictor Model Name"), Required] public string PredictorModelName { get; set; }
[Display(Name = "Properties Changed For Distance"), Required] public bool? PropertiesChangedForDistance { get; set; }
[Display(Name = "Properties Changed For Faces"), Required] public bool? PropertiesChangedForFaces { get; set; }
[Display(Name = "Properties Changed For Index"), Required] public bool? PropertiesChangedForIndex { get; set; }
[Display(Name = "Properties Changed For Metadata"), Required] public bool? PropertiesChangedForMetadata { get; set; }
[Display(Name = "Properties Changed For Resize"), Required] public bool? PropertiesChangedForResize { get; set; }
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration? PropertyConfiguration { get; set; }
[Display(Name = "Reverse"), Required] public bool? Reverse { get; set; }
[Display(Name = "Save Face Landmark For Output Resolutions"), Required] public string[] SaveFaceLandmarkForOutputResolutions { get; set; }
[Display(Name = "Save Full Year Of Random Files"), Required] public bool? SaveFullYearOfRandomFiles { get; set; }
[Display(Name = "Save Resized Subfiles"), Required] public bool? SaveResizedSubfiles { get; set; }
[Display(Name = "Save Shortcuts"), Required] public bool? SaveShortcuts { get; set; }
[Display(Name = "Skip Search"), Required] public bool? SkipSearch { get; set; }
[Display(Name = "Test Distance Results"), Required] public bool? TestDistanceResults { get; set; }
[Display(Name = "Valid Resolutions"), Required] public string[] ValidResolutions { get; set; }
public Configuration()
{
CheckJsonForDistanceResults = null;
CrossDirectoryMaxItemsInDistanceCollection = null;
DistanceFactor = null;
ForceMetadataLastWriteTimeToCreationTime = null;
ForceResizeLastWriteTimeToCreationTime = null;
IgnoreExtensions = Array.Empty<string>();
IgnoreRelativePaths = Array.Empty<string>();
JuliePhares = Array.Empty<string>();
LoadOrCreateThenSaveDirectoryDistanceResults = null;
LoadOrCreateThenSaveDistanceResults = null;
LoadOrCreateThenSaveImageFacesResults = null;
LoadOrCreateThenSaveIndex = null;
LocationConfidenceFactor = null;
MappedMaxIndex = null;
MaxItemsInDistanceCollection = null;
MixedYearRelativePaths = Array.Empty<string>();
ModelDirectory = string.Empty;
ModelName = string.Empty;
NumJitters = null;
OutputExtension = string.Empty;
OutputQuality = null;
OutputResolutions = Array.Empty<string>();
OverrideForFaceImages = null;
OverrideForFaceLandmarkImages = null;
OverrideForResizeImages = null;
PaddingLoops = null;
PredictorModelName = string.Empty;
PropertiesChangedForDistance = null;
PropertiesChangedForFaces = null;
PropertiesChangedForIndex = null;
PropertiesChangedForMetadata = null;
PropertiesChangedForResize = null;
Reverse = null;
SaveFaceLandmarkForOutputResolutions = Array.Empty<string>();
SaveFullYearOfRandomFiles = null;
SaveResizedSubfiles = null;
SaveShortcuts = null;
SkipSearch = null;
TestDistanceResults = null;
ValidResolutions = Array.Empty<string>();
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
}

View File

@ -0,0 +1,148 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Tests.Models;
public class Configuration
{
protected readonly bool? _CheckJsonForDistanceResults;
protected readonly int? _CrossDirectoryMaxItemsInDistanceCollection;
protected readonly int? _DistanceFactor;
protected readonly bool? _ForceMetadataLastWriteTimeToCreationTime;
protected readonly bool? _ForceResizeLastWriteTimeToCreationTime;
protected readonly string[] _IgnoreExtensions;
protected readonly string[] _IgnoreRelativePaths;
protected readonly string[] _JuliePhares;
protected readonly bool? _LoadOrCreateThenSaveDirectoryDistanceResults;
protected readonly bool? _LoadOrCreateThenSaveDistanceResults;
protected readonly bool? _LoadOrCreateThenSaveImageFacesResults;
protected readonly bool? _LoadOrCreateThenSaveIndex;
protected readonly int? _LocationConfidenceFactor;
protected readonly int? _MappedMaxIndex;
protected readonly int? _MaxItemsInDistanceCollection;
protected readonly string[] _MixedYearRelativePaths;
protected readonly string _ModelDirectory;
protected readonly string _ModelName;
protected readonly int? _NumJitters;
protected readonly string _OutputExtension;
protected readonly int? _OutputQuality;
protected readonly string[] _OutputResolutions;
protected readonly bool? _OverrideForFaceImages;
protected readonly bool? _OverrideForFaceLandmarkImages;
protected readonly bool? _OverrideForResizeImages;
protected readonly int? _PaddingLoops;
protected readonly string _PredictorModelName;
protected readonly bool? _PropertiesChangedForDistance;
protected readonly bool? _PropertiesChangedForFaces;
protected readonly bool? _PropertiesChangedForIndex;
protected readonly bool? _PropertiesChangedForMetadata;
protected readonly bool? _PropertiesChangedForResize;
protected Property.Models.Configuration? _PropertyConfiguration;
protected readonly bool? _Reverse;
protected readonly string[] _SaveFaceLandmarkForOutputResolutions;
protected readonly bool? _SaveFullYearOfRandomFiles;
protected readonly bool? _SaveResizedSubfiles;
protected readonly bool? _SaveShortcuts;
protected readonly bool? _SkipSearch;
protected readonly bool? _TestDistanceResults;
protected readonly string[] _ValidResolutions;
public bool? CheckJsonForDistanceResults => _CheckJsonForDistanceResults;
public int? CrossDirectoryMaxItemsInDistanceCollection => _CrossDirectoryMaxItemsInDistanceCollection;
public int? DistanceFactor => _DistanceFactor;
public bool? ForceMetadataLastWriteTimeToCreationTime => _ForceMetadataLastWriteTimeToCreationTime;
public bool? ForceResizeLastWriteTimeToCreationTime => _ForceResizeLastWriteTimeToCreationTime;
public string[] IgnoreExtensions => _IgnoreExtensions;
public string[] IgnoreRelativePaths => _IgnoreRelativePaths;
public string[] JuliePhares => _JuliePhares;
public bool? LoadOrCreateThenSaveDirectoryDistanceResults => _LoadOrCreateThenSaveDirectoryDistanceResults;
public bool? LoadOrCreateThenSaveDistanceResults => _LoadOrCreateThenSaveDistanceResults;
public bool? LoadOrCreateThenSaveImageFacesResults => _LoadOrCreateThenSaveImageFacesResults;
public bool? LoadOrCreateThenSaveIndex => _LoadOrCreateThenSaveIndex;
public int? LocationConfidenceFactor => _LocationConfidenceFactor;
public int? MappedMaxIndex => _MappedMaxIndex;
public int? MaxItemsInDistanceCollection => _MaxItemsInDistanceCollection;
public string[] MixedYearRelativePaths => _MixedYearRelativePaths;
public string ModelDirectory => _ModelDirectory;
public string ModelName => _ModelName;
public int? NumJitters => _NumJitters;
public string OutputExtension => _OutputExtension;
public int? OutputQuality => _OutputQuality;
public string[] OutputResolutions => _OutputResolutions;
public bool? OverrideForFaceImages => _OverrideForFaceImages;
public bool? OverrideForFaceLandmarkImages => _OverrideForFaceLandmarkImages;
public bool? OverrideForResizeImages => _OverrideForResizeImages;
public int? PaddingLoops => _PaddingLoops;
public string PredictorModelName => _PredictorModelName;
public bool? PropertiesChangedForDistance => _PropertiesChangedForDistance;
public bool? PropertiesChangedForFaces => _PropertiesChangedForFaces;
public bool? PropertiesChangedForIndex => _PropertiesChangedForIndex;
public bool? PropertiesChangedForMetadata => _PropertiesChangedForMetadata;
public bool? PropertiesChangedForResize => _PropertiesChangedForResize;
public Property.Models.Configuration? PropertyConfiguration => _PropertyConfiguration;
public bool? Reverse => _Reverse;
public string[] SaveFaceLandmarkForOutputResolutions => _SaveFaceLandmarkForOutputResolutions;
public bool? SaveFullYearOfRandomFiles => _SaveFullYearOfRandomFiles;
public bool? SaveResizedSubfiles => _SaveResizedSubfiles;
public bool? SaveShortcuts => _SaveShortcuts;
public bool? SkipSearch => _SkipSearch;
public bool? TestDistanceResults => _TestDistanceResults;
public string[] ValidResolutions => _ValidResolutions;
[JsonConstructor]
public Configuration(bool? checkJsonForDistanceResults, int? crossDirectoryMaxItemsInDistanceCollection, int? distanceFactor, bool? forceMetadataLastWriteTimeToCreationTime, bool? forceResizeLastWriteTimeToCreationTime, string[] ignoreExtensions, string[] ignoreRelativePaths, string[] juliePhares, bool? loadOrCreateThenSaveDirectoryDistanceResults, bool? loadOrCreateThenSaveDistanceResults, bool? loadOrCreateThenSaveImageFacesResults, bool? loadOrCreateThenSaveIndex, int? locationConfidenceFactor, int? mappedMaxIndex, int? maxItemsInDistanceCollection, string[] mixedYearRelativePaths, string modelDirectory, string modelName, int? numJitters, string outputExtension, int? outputQuality, string[] outputResolutions, bool? overrideForFaceImages, bool? overrideForFaceLandmarkImages, bool? overrideForResizeImages, int? paddingLoops, string predictorModelName, bool? propertiesChangedForDistance, bool? propertiesChangedForFaces, bool? propertiesChangedForIndex, bool? propertiesChangedForMetadata, bool? propertiesChangedForResize, Property.Models.Configuration? propertyConfiguration, bool? reverse, string[] saveFaceLandmarkForOutputResolutions, bool? saveFullYearOfRandomFiles, bool? saveResizedSubfiles, bool? saveShortcuts, bool? skipSearch, bool? testDistanceResults, string[] validResolutions)
{
_CheckJsonForDistanceResults = checkJsonForDistanceResults;
_CrossDirectoryMaxItemsInDistanceCollection = crossDirectoryMaxItemsInDistanceCollection;
_DistanceFactor = distanceFactor;
_ForceMetadataLastWriteTimeToCreationTime = forceMetadataLastWriteTimeToCreationTime;
_ForceResizeLastWriteTimeToCreationTime = forceResizeLastWriteTimeToCreationTime;
_IgnoreExtensions = ignoreExtensions;
_IgnoreRelativePaths = ignoreRelativePaths;
_JuliePhares = juliePhares;
_LoadOrCreateThenSaveDirectoryDistanceResults = loadOrCreateThenSaveDirectoryDistanceResults;
_LoadOrCreateThenSaveDistanceResults = loadOrCreateThenSaveDistanceResults;
_LoadOrCreateThenSaveImageFacesResults = loadOrCreateThenSaveImageFacesResults;
_LoadOrCreateThenSaveIndex = loadOrCreateThenSaveIndex;
_LocationConfidenceFactor = locationConfidenceFactor;
_MappedMaxIndex = mappedMaxIndex;
_MaxItemsInDistanceCollection = maxItemsInDistanceCollection;
_MixedYearRelativePaths = mixedYearRelativePaths;
_ModelDirectory = modelDirectory;
_ModelName = modelName;
_NumJitters = numJitters;
_OutputExtension = outputExtension;
_OutputQuality = outputQuality;
_OutputResolutions = outputResolutions;
_OverrideForFaceImages = overrideForFaceImages;
_OverrideForFaceLandmarkImages = overrideForFaceLandmarkImages;
_OverrideForResizeImages = overrideForResizeImages;
_PaddingLoops = paddingLoops;
_PredictorModelName = predictorModelName;
_PropertiesChangedForDistance = propertiesChangedForDistance;
_PropertiesChangedForFaces = propertiesChangedForFaces;
_PropertiesChangedForIndex = propertiesChangedForIndex;
_PropertiesChangedForMetadata = propertiesChangedForMetadata;
_PropertiesChangedForResize = propertiesChangedForResize;
_PropertyConfiguration = propertyConfiguration;
_Reverse = reverse;
_SaveFaceLandmarkForOutputResolutions = saveFaceLandmarkForOutputResolutions;
_SaveFullYearOfRandomFiles = saveFullYearOfRandomFiles;
_SaveResizedSubfiles = saveResizedSubfiles;
_SaveShortcuts = saveShortcuts;
_SkipSearch = skipSearch;
_TestDistanceResults = testDistanceResults;
_ValidResolutions = validResolutions;
}
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
public void Set(Property.Models.Configuration configuration) => _PropertyConfiguration = configuration;
public void Update() => _PropertyConfiguration?.Update();
}

View File

@ -0,0 +1,40 @@
using Microsoft.Extensions.Configuration;
using System.Text.Json;
namespace View_by_Distance.Tests.Models.Stateless;
public abstract class AppSettings
{
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
{
Models.AppSettings? result;
Binder.AppSettings appSettings = configurationRoot.Get<Binder.AppSettings>();
string json = JsonSerializer.Serialize(appSettings, new JsonSerializerOptions() { WriteIndented = true });
result = JsonSerializer.Deserialize<Models.AppSettings>(json);
if (result is null)
throw new Exception(json);
if (string.IsNullOrEmpty(result.Company))
throw new Exception(json);
string jsonThis = result.ToString();
if (jsonThis != json)
{
int? check = null;
int min = new int[] { json.Length, jsonThis.Length }.Min();
for (int i = 0; i < min; i++)
{
if (json[i] == jsonThis[i])
continue;
check = i;
break;
}
if (check is null)
throw new Exception();
string a = json[..check.Value].Split(',')[^1];
string b = json[check.Value..].Split(',')[0];
throw new Exception($"{a}{b}");
}
return result;
}
}

View File

@ -0,0 +1,44 @@
using Microsoft.Extensions.Configuration;
using Phares.Shared;
using System.Text.Json;
namespace View_by_Distance.Tests.Models.Stateless;
public abstract class Configuration
{
public static Models.Configuration Get(IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, string workingDirectory, Property.Models.Configuration propertyConfiguration)
{
Models.Configuration? result;
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
string section = string.Concat(environmentName, ":", nameof(Binder.Configuration));
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
Binder.Configuration configuration = configurationSection.Get<Binder.Configuration>();
string json = JsonSerializer.Serialize(configuration, new JsonSerializerOptions() { WriteIndented = true });
result = JsonSerializer.Deserialize<Models.Configuration>(json);
if (result is null)
throw new Exception(json);
string jsonThis = result.ToString();
result.Set(propertyConfiguration);
result.Update();
if (jsonThis != json)
{
int? check = null;
int min = new int[] { json.Length, jsonThis.Length }.Min();
for (int i = 0; i < min; i++)
{
if (json[i] == jsonThis[i])
continue;
check = i;
break;
}
if (check is null)
throw new Exception();
string a = json[..check.Value].Split(',')[^1];
string b = json[check.Value..].Split(',')[0];
throw new Exception($"{a}{b}");
}
return result;
}
}

52
Tests/Tests.csproj Normal file
View File

@ -0,0 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)'=='true'">
<DefineConstants>Windows</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsOSX)'=='true'">
<DefineConstants>OSX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinux)'=='true'">
<DefineConstants>Linux</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog" Version="2.10.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
<ProjectReference Include="..\Property\Property.csproj" />
<ProjectReference Include="..\Metadata\Metadata.csproj" />
<ProjectReference Include="..\Resize\Resize.csproj" />
<ProjectReference Include="..\Property-Compare\Property-Compare.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

71
Tests/UnitTestExample.cs Normal file
View File

@ -0,0 +1,71 @@
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Serilog;
using System.Reflection;
using System.Diagnostics;
using View_by_Distance.Tests.Models;
using View_by_Distance.Shared.Models.Stateless.Methods;
using Phares.Shared;
namespace View_by_Distance.Tests;
[TestClass]
public class UnitTestExample
{
private readonly ILogger _Logger;
private readonly AppSettings _AppSettings;
private readonly string _WorkingDirectory;
private readonly Configuration _Configuration;
private readonly IsEnvironment _IsEnvironment;
private readonly IConfigurationRoot _ConfigurationRoot;
private readonly Property.Models.Configuration _PropertyConfiguration;
public UnitTestExample()
{
ILogger logger;
AppSettings appSettings;
string workingDirectory;
Configuration configuration;
IsEnvironment isEnvironment;
IConfigurationRoot configurationRoot;
LoggerConfiguration loggerConfiguration = new();
Property.Models.Configuration propertyConfiguration;
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonFile(isEnvironment.AppSettingsFileName);
configurationRoot = configurationBuilder.Build();
appSettings = Models.Stateless.AppSettings.Get(configurationRoot);
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
Log.Logger = loggerConfiguration.CreateLogger();
logger = Log.ForContext<UnitTestExample>();
propertyConfiguration = Property.Models.Stateless.Configuration.Get(isEnvironment, configurationRoot, workingDirectory);
configuration = Models.Stateless.Configuration.Get(isEnvironment, configurationRoot, workingDirectory, propertyConfiguration);
logger.Information("Complete");
_Logger = logger;
_AppSettings = appSettings;
_Configuration = configuration;
_IsEnvironment = isEnvironment;
_WorkingDirectory = workingDirectory;
_ConfigurationRoot = configurationRoot;
_PropertyConfiguration = propertyConfiguration;
}
[TestMethod]
public void TestMethodNull()
{
Assert.IsFalse(_Logger is null);
Assert.IsFalse(_AppSettings is null);
Assert.IsFalse(_Configuration is null);
Assert.IsFalse(_IsEnvironment is null);
Assert.IsFalse(_WorkingDirectory is null);
Assert.IsFalse(_ConfigurationRoot is null);
Assert.IsFalse(_PropertyConfiguration is null);
}
}

174
Tests/UnitTestResize.cs Normal file
View File

@ -0,0 +1,174 @@
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Serilog;
using System.Reflection;
using System.Diagnostics;
using View_by_Distance.Tests.Models;
using View_by_Distance.Shared.Models.Stateless.Methods;
using Phares.Shared;
using View_by_Distance.Resize.Models;
using System.Drawing.Imaging;
using View_by_Distance.Metadata.Models;
namespace View_by_Distance.Tests;
[TestClass]
public class UnitTestResize
{
private readonly ILogger _Logger;
private readonly AppSettings _AppSettings;
private readonly string _WorkingDirectory;
private readonly Configuration _Configuration;
private readonly IsEnvironment _IsEnvironment;
private readonly IConfigurationRoot _ConfigurationRoot;
private readonly Property.Models.Configuration _PropertyConfiguration;
public UnitTestResize()
{
ILogger logger;
AppSettings appSettings;
string workingDirectory;
Configuration configuration;
IsEnvironment isEnvironment;
IConfigurationRoot configurationRoot;
LoggerConfiguration loggerConfiguration = new();
Property.Models.Configuration propertyConfiguration;
Assembly assembly = Assembly.GetExecutingAssembly();
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonFile(isEnvironment.AppSettingsFileName);
configurationRoot = configurationBuilder.Build();
appSettings = Models.Stateless.AppSettings.Get(configurationRoot);
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
Log.Logger = loggerConfiguration.CreateLogger();
logger = Log.ForContext<UnitTestResize>();
propertyConfiguration = Property.Models.Stateless.Configuration.Get(isEnvironment, configurationRoot, workingDirectory);
configuration = Models.Stateless.Configuration.Get(isEnvironment, configurationRoot, workingDirectory, propertyConfiguration);
logger.Information("Complete");
_Logger = logger;
_AppSettings = appSettings;
_Configuration = configuration;
_IsEnvironment = isEnvironment;
_WorkingDirectory = workingDirectory;
_ConfigurationRoot = configurationRoot;
_PropertyConfiguration = propertyConfiguration;
}
[TestMethod]
public void TestMethodNull()
{
Assert.IsFalse(_Logger is null);
Assert.IsFalse(_AppSettings is null);
Assert.IsFalse(_Configuration is null);
Assert.IsFalse(_IsEnvironment is null);
Assert.IsFalse(_WorkingDirectory is null);
Assert.IsFalse(_ConfigurationRoot is null);
Assert.IsFalse(_PropertyConfiguration is null);
}
private Property.Models.PropertyLogic GetPropertyLogic()
{
Property.Models.PropertyLogic result;
if (_AppSettings.MaxDegreeOfParallelism is null)
throw new Exception($"{nameof(_AppSettings.MaxDegreeOfParallelism)} is null!");
if (_Configuration?.PropertyConfiguration is null)
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
result = new(_AppSettings.MaxDegreeOfParallelism.Value, _Configuration.PropertyConfiguration);
return result;
}
[TestMethod]
public void TestMethodResize()
{
// string sourceFileName = "IMG_0067.jpg";
// string sourceDirectoryName = "Mackenzie Prom 2017";
string sourceFileName = "Fall 2005 (113).jpg";
string sourceDirectoryName = "=2005.3 Fall";
if (_Configuration.ForceMetadataLastWriteTimeToCreationTime is null)
throw new Exception($"{nameof(_Configuration.ForceMetadataLastWriteTimeToCreationTime)} is null!");
if (_Configuration.ForceResizeLastWriteTimeToCreationTime is null)
throw new Exception($"{nameof(_Configuration.ForceResizeLastWriteTimeToCreationTime)} is null!");
if (_Configuration.OutputQuality is null)
throw new Exception($"{nameof(_Configuration.OutputQuality)} is null!");
if (_Configuration.OverrideForResizeImages is null)
throw new Exception($"{nameof(_Configuration.OverrideForResizeImages)} is null!");
if (_Configuration.PropertiesChangedForMetadata is null)
throw new Exception($"{nameof(_Configuration.PropertiesChangedForMetadata)} is null!");
if (_Configuration.PropertiesChangedForResize is null)
throw new Exception($"{nameof(_Configuration.PropertiesChangedForResize)} is null!");
int g = 1;
int r = 1;
string original = "Original";
List<string> parseExceptions = new();
string modelName = "model.ToString()";
Property.Models.A_Property? property = null;
Property.Models.PropertyHolder propertyHolder;
Dictionary<string, int[]> imageResizeKeyValuePairs;
List<Tuple<string, DateTime>> subFileTuples = new();
List<KeyValuePair<string, string>> metadataCollection;
string predictorModelName = "predictorModel.ToString()";
int length = _PropertyConfiguration.RootDirectory.Length;
string outputResolution = _Configuration.OutputResolutions[0];
Property.Models.PropertyLogic propertyLogic = GetPropertyLogic();
string sourceDirectory = Path.Combine(_PropertyConfiguration.RootDirectory, sourceDirectoryName);
string aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_PropertyConfiguration, nameof(Property.Models.A_Property), "{}");
B_Metadata metadata = new(_Configuration.ForceMetadataLastWriteTimeToCreationTime.Value, _Configuration.PropertiesChangedForMetadata.Value);
(ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters) = C_Resize.GetTuple(_Configuration.OutputExtension, _Configuration.OutputQuality.Value);
C_Resize resize = new(_Configuration.ForceResizeLastWriteTimeToCreationTime.Value, _Configuration.OverrideForResizeImages.Value, _Configuration.PropertiesChangedForResize.Value, _Configuration.ValidResolutions, imageCodecInfo, encoderParameters);
propertyLogic.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
modelName,
predictorModelName,
sourceDirectory,
nameof(Property.Models.A_Property),
outputResolution,
includeResizeGroup: false,
includeModel: false,
includePredictorModel: false,
contentDescription: string.Empty,
singletonDescription: "Properties for each image",
collectionDescription: string.Empty));
metadata.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
modelName,
predictorModelName,
sourceDirectory,
nameof(B_Metadata),
outputResolution,
includeResizeGroup: false,
includeModel: false,
includePredictorModel: false,
contentDescription: string.Empty,
singletonDescription: "Metadata as key value pairs",
collectionDescription: string.Empty));
resize.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
modelName,
predictorModelName,
sourceDirectory,
nameof(C_Resize),
outputResolution,
includeResizeGroup: true,
includeModel: false,
includePredictorModel: false,
contentDescription: "Resized image",
singletonDescription: "Resize dimensions for each resolution",
collectionDescription: string.Empty));
string sourceDirectoryFile = ".json";
FileInfo fileInfo = new(Path.Combine(sourceDirectory, sourceFileName));
string relativePath = Property.Models.Stateless.IPath.GetRelativePath(fileInfo.FullName, length);
sourceDirectory = Path.Combine(aPropertySingletonDirectory, sourceDirectoryName);
propertyHolder = new(g, sourceDirectory, sourceDirectoryFile, relativePath, r, fileInfo, property, false, false, null, null, null);
if (propertyHolder.ImageFileInfo is null)
throw new Exception($"{nameof(propertyHolder.ImageFileInfo)} is null!");
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(propertyHolder.ImageFileInfo.FullName);
property = propertyLogic.GetProperty(propertyLogic.AngleBracketCollection[0], propertyHolder, subFileTuples, parseExceptions);
(int _, metadataCollection) = metadata.GetMetadataCollection(subFileTuples, parseExceptions, propertyHolder.ImageFileInfo.FullName, propertyHolder.RelativePath, fileNameWithoutExtension);
imageResizeKeyValuePairs = resize.GetResizeKeyValuePairs(subFileTuples, parseExceptions, original, metadataCollection, property, propertyHolder.ImageFileInfo.FullName, propertyHolder.RelativePath, fileNameWithoutExtension);
FileInfo resizedFileInfo = new(Path.Combine(resize.AngleBracketCollection[0].Replace("<>", "()"), Path.GetFileName(propertyHolder.ImageFileInfo.FullName)));
resize.SaveResizedSubfile(outputResolution, subFileTuples, propertyHolder.ImageFileInfo.FullName, original, property, imageResizeKeyValuePairs, resizedFileInfo);
}
}

View File

@ -0,0 +1,519 @@
{
"Company": "Mike Phares",
"Linux": {},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Log4netProvider": "Debug",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"MaxDegreeOfParallelism": 6,
"Serilog": {
"Using": [
"Serilog.Sinks.Console",
"Serilog.Sinks.File"
],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "Debug",
"Args": {
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
}
},
{
"Name": "Console",
"Args": {
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "%workingDirectory% - Log/log-.txt",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}",
"rollingInterval": "Hour"
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithThreadId"
],
"Properties": {
"Application": "Sample"
}
},
"WorkingDirectoryName": "PharesApps",
"Windows": {
"Configuration": {
"CheckJsonForDistanceResults": true,
"CrossDirectoryMaxItemsInDistanceCollection": 7,
"DateGroup": "2022-07-27",
"DistanceFactor": 8,
"FileNameDirectorySeparator": ".Z.",
"ForceMetadataLastWriteTimeToCreationTime": true,
"ForcePropertyLastWriteTimeToCreationTime": false,
"ForceResizeLastWriteTimeToCreationTime": true,
"LoadOrCreateThenSaveDirectoryDistanceResults": false,
"LoadOrCreateThenSaveDistanceResults": false,
"LoadOrCreateThenSaveImageFacesResults": true,
"LoadOrCreateThenSaveIndex": false,
"LocationConfidenceFactor": 2,
"MappedMaxIndex": 1034720,
"MaxImagesInDirectoryForTopLevelFirstPass": 50,
"MaxItemsInDistanceCollection": 50,
"ModelDirectory": "C:/GitHub/dlib-models",
"ModelName": "Hog",
"NumJitters": 1,
"OutputExtension": ".jpg",
"OutputQuality": 95,
"OverrideForFaceImages": false,
"OverrideForFaceLandmarkImages": false,
"OverrideForResizeImages": false,
"PaddingLoops": 5,
"Pattern": "[^ABCDEFGHIJKLMNOPQRSTUVWXYZbcdfghjklmnpqrstvwxyz0-9]",
"PredictorModelName": "Large",
"PopulatePropertyId": true,
"PropertiesChangedForDistance": false,
"PropertiesChangedForFaces": false,
"PropertiesChangedForIndex": false,
"PropertiesChangedForMetadata": false,
"PropertiesChangedForProperty": false,
"PropertiesChangedForResize": false,
"Reverse": false,
"xRootDirectory": "C:/Tmp/phares/Pictures",
"RootDirectory": "F:/Tmp/Phares/Compare/Images 2022-07-27 - 20220727 - III",
"SaveFullYearOfRandomFiles": true,
"SaveResizedSubFiles": true,
"SaveShortcuts": true,
"SkipSearch": false,
"TestDistanceResults": true,
"WriteBitmapDataBytes": false,
"IgnoreExtensions": [
".gif",
".GIF"
],
"JuliePhares": [
"1500-01-16_00",
"1500-01-19_00",
"1500-01-20_00",
"1500-01-21_00",
"1500-01-25_00",
"1500-01-26_00",
"1500-01-27_00",
"1500-02-13_00",
"1500-02-17_00",
"1500-02-24_00",
"1500-02-25_00",
"1500-04-03_00",
"1500-04-06_00",
"1500-04-19_00",
"1500-05-03_00",
"1500-05-18_00",
"1500-05-28_00",
"1500-06-16_00",
"1500-06-26_00",
"1500-06-27_00",
"1500-07-07_00",
"1500-07-16_00",
"1720-09-30_05",
"1500-07-26_00",
"1500-08-03_00",
"1500-08-23_00",
"1500-08-24_00",
"1500-09-16_00",
"1500-09-21_00",
"1500-09-28_00",
"1500-10-14_00",
"1500-11-07_00",
"1500-11-09_00",
"1720-09-28_20",
"1501-01-08_00",
"1501-01-12_00",
"1501-01-13_00",
"1501-01-30_00",
"1501-03-09_00",
"1501-03-14_00",
"1501-03-22_00",
"1501-04-07_00",
"1501-04-10_00",
"1501-04-19_00",
"1501-05-06_00",
"1956-09-19_00",
"2012-09-17_00",
"1998-05-21_00",
"1960-03-01_00",
"1976-03-08_00",
"2007-09-07_00",
"2000-04-07_00",
"1980-01-17_00",
"1958-01-30_00",
"1976-01-05_00",
"1982-05-02_00"
],
"xOutputResolutions": [
"176 x 176",
"256 x 256",
"353 x 353",
"1024 x 768"
],
"OutputResolutions": [
"1920 x 1080"
],
"PropertyContentCollectionFiles": [],
"SaveFaceLandmarkForOutputResolutions": [
"176 x 176",
"256 x 256"
],
"ValidImageFormatExtensions": [
".bmp",
".BMP",
".gif",
".GIF",
".jpeg",
".JPEG",
".jpg",
".JPG",
".png",
".PNG",
".tiff",
".TIFF"
],
"ValidMetadataExtensions": [
".3gp",
".3GP",
".amr",
".AMR",
".avi",
".AVI",
".bmp",
".BMP",
".gif",
".GIF",
".ico",
".ICO",
".jpeg",
".JPEG",
".jpg",
".JPG",
".m4v",
".M4V",
".mov",
".MOV",
".mp4",
".MP4",
".mta",
".MTA",
".png",
".PNG",
".tiff",
".TIFF"
],
"ValidResolutions": [
"176 x 176",
"256 x 256",
"353 x 353",
"1024 x 768",
"1280 x 720",
"1280 x 800",
"1376 x 768",
"1600 x 1200",
"1920 x 1080",
"2256 x 1496",
"3840 x 2160",
"7680 x 4320"
],
"VerifyToSeason": [
". 2000",
". 2001",
". 2002",
". 2003",
". 2004",
". 2005",
". 2006",
". 2007",
". 2008",
". 2009",
". 2010",
". 2011",
". 2012",
". 2013",
". 2014",
". 2015",
". 2016",
". 2017",
". 2018",
". 2019",
". 2020",
". 2021",
". 2022",
". 2023",
". 2024",
". 2025",
". 2026",
". 2027",
". 2028",
". 2029",
"=2000.0 Winter",
"=2002.1 Spring",
"=2002.4 Winter",
"=2003.0 Winter",
"=2003.1 Spring",
"=2003.3 Fall",
"=2003.4 Winter",
"=2004.0 Winter",
"=2005.1 Spring",
"=2005.2 Summer",
"=2005.3 Fall",
"=2005.4 Winter",
"=2006.0 Winter",
"=2006.1 Spring",
"=2006.3 Fall",
"=2007.0 Winter",
"=2007.2 Summer Logan Michael",
"=2007.2 Summer",
"=2007.3 Fall Logan Michael",
"=2007.4 Winter Logan Michael",
"=2008.0 Winter Logan Michael",
"=2008.1 Spring Logan Michael",
"=2008.2 Summer Logan Michael",
"=2008.2 Summer",
"=2008.3 Fall Logan Michael",
"=2009.0 Winter Logan Michael",
"=2009.0 Winter",
"=2009.1 Spring Logan Michael",
"=2009.1 Spring",
"=2009.2 Summer Logan Michael",
"=2009.2 Summer",
"=2009.3 Fall Logan Michael",
"=2009.3 Fall",
"=2009.4 Winter Logan Michael",
"=2009.4 Winter",
"=2010.0 Winter Logan Michael",
"=2010.0 Winter",
"=2010.1 Spring Logan Michael",
"=2010.1 Spring",
"=2010.2 Summer",
"=2010.3 Fall Logan Michael",
"=2010.3 Fall",
"=2010.4 Winter",
"=2011.0 Winter",
"=2011.1 Spring",
"=2011.2 Summer",
"=2011.3 Fall",
"=2011.4 Winter",
"=2012.0 Winter Chelsea 2012",
"=2012.0 Winter Chelsea",
"=2012.0 Winter",
"=2012.1 Spring Chelsea",
"=2012.1 Spring",
"=2012.2 Summer Chelsea",
"=2012.2 Summer",
"=2012.3 Fall Chelsea",
"=2012.3 Fall",
"=2012.4 Winter Chelsea",
"=2012.4 Winter",
"=2013.0 Winter Chelsea 2013",
"=2013.0 Winter Chelsea",
"=2013.0 Winter",
"=2013.1 Spring",
"=2013.2 Summer Chelsea",
"=2013.2 Summer",
"=2013.3 Fall Chelsea",
"=2013.3 Fall",
"=2013.4 Winter",
"=2014.0 Winter",
"=2014.1 Spring",
"=2014.2 Summer",
"=2014.3 Fall",
"=2014.4 Winter",
"=2015.0 Winter",
"=2015.1 Spring",
"=2015.2 Summer",
"=2015.3 Fall",
"=2015.4 Winter",
"=2016.0 Winter",
"=2016.1 Spring",
"=2016.2 Summer",
"=2016.3 Fall",
"=2016.4 Winter",
"=2017.1 Spring",
"=2017.2 Summer",
"=2017.3 Fall",
"=2017.4 Winter",
"=2018.0 Winter",
"=2018.1 Spring",
"=2018.3 Fall",
"=2018.4 Winter",
"=2019.0 Winter",
"=2019.1 Spring",
"=2019.2 Summer",
"=2019.3 Fall",
"=2019.4 Winter",
"=2020.0 Winter",
"=2020.1 Spring",
"=2020.2 Summer",
"=2020.3 Fall",
"=2020.4 Winter",
"=2021.1 Spring",
"=2021.2 Summer",
"=2021.3 Fall",
"=2021.4 Winter",
"=2022.0 Winter",
"=2022.1 Spring",
"Anthem 2015",
"April 2010",
"April 2013",
"December 2006",
"December 2010",
"Fall 2005",
"Fall 2015",
"Fall 2016",
"Fall 2017",
"Fall 2018",
"Fall 2019",
"Fall 2020",
"Fall 2021",
"February 2010",
"January 2015",
"July 2010",
"June 2010",
"Kids 2005",
"March 2013",
"May 2010",
"May 2011",
"May 2013",
"October 2005",
"October 2014",
"Spring 2013",
"Spring 2014",
"Spring 2016",
"Spring 2018",
"Spring 2019",
"Spring 2020",
"Summer 2011",
"Summer 2012",
"Summer 2013",
"Summer 2014",
"Summer 2015",
"Summer 2016",
"Summer 2017",
"Summer 2018",
"Summer 2020",
"Summer 2021",
"Winter 2015",
"Winter 2016",
"Winter 2017",
"Winter 2018",
"Winter 2019-2020",
"Winter 2020",
"zzz =2005.0 Winter Tracy Pictures",
"zzz =2005.1 Spring Tracy Pictures",
"zzz =2005.2 Summer Tracy Pictures",
"zzz =2005.3 Fall Tracy Pictures",
"zzz =2005.4 Winter Tracy Pictures",
"zzz =2006.1 Spring Tracy Pictures",
"zzz =2007.0 Winter Tracy Pictures",
"zzz =2007.2 Summer Tracy Pictures",
"zzz =2008.0 Winter Tracy Pictures",
"zzz =2008.2 Summer Tracy Pictures",
"zzz =2009.0 Winter Tracy Pictures",
"zzz =2009.2 Summer Tracy Pictures",
"zzz =2009.3 Fall Tracy Pictures",
"zzz =2009.4 Winter Tracy Pictures",
"zzz =2010.0 Winter Tracy Pictures",
"zzz =2010.1 Spring Tracy Pictures",
"zzz =2010.2 Summer Tracy Pictures",
"zzz =2010.3 Fall Tracy Pictures",
"zzz =2011.0 Winter Tracy Pictures",
"zzz =2011.1 Spring Tracy Pictures",
"zzz =2011.2 Summer Tracy Pictures",
"zzz =2011.3 Fall Tracy Pictures",
"zzz =2011.4 Winter Tracy Pictures",
"zzz =2012.0 Winter Tracy Pictures",
"zzz =2012.1 Spring Tracy Pictures",
"zzz =2012.2 Summer Tracy Pictures",
"zzz =2012.3 Fall Tracy Pictures",
"zzz =2012.4 Winter Tracy Pictures",
"zzz =2013.0 Winter Tracy Pictures",
"zzz =2013.1 Spring Tracy Pictures",
"zzz =2013.2 Summer Tracy Pictures",
"zzz =2013.3 Fall Tracy Pictures",
"zzz =2013.4 Winter Tracy Pictures",
"zzz =2014.0 Winter Tracy Pictures",
"zzz =2014.1 Spring Tracy Pictures",
"zzz =2014.2 Summer Tracy Pictures",
"zzz =2014.3 Fall Tracy Pictures",
"zzz =2014.4 Winter Tracy Pictures",
"zzz =2015.0 Winter Tracy Pictures"
],
"MixedYearRelativePaths": [
"Edited",
"Phares Slides",
"Rex Memorial",
"Scanned Grandma's Quilt",
"Scanned Pictures Of Kids",
"Scanned Prints",
"Slide in Name Order Originals (622)",
"Slides Pictures"
],
"IgnoreRelativePaths": [
"3757 W Whitman 2017",
"501 Playful Meadows 2006",
"501 Playful Meadows 2007",
"501 Playful Meadows 2008",
"501 Playful Meadows 2009",
"501 Playful Meadows 2010",
"501 Playful Meadows 2013",
"501 Playful Meadows 2015",
"6309 Evesham 2003",
"6309 Evesham 2004",
"Crystal's Wedding 2003",
"Danny's Wedding 2009",
"Door images 2019",
"Family Pictures 2006",
"Family Pictures 2007",
"Family Pictures 2011",
"Family Pictures 2013",
"GrandPrix 2004",
"Kids School Pictures 2004",
"Kristy 2002",
"Kristy Parents Wedding 2005",
"Logan Ultrasound 2007",
"Mandy's Dogs 2008",
"Motorcycles 2010",
"Motorcycles 2013",
"Motorcycles 2014",
"Phares Slides",
"Portrait Innovations April 2008",
"Portrait Innovations December 2007",
"Portrait Innovations June 2008",
"Portrait Innovations March 2012",
"The guys house 2000",
"Tracy Pictures 2005",
"Tracy Pictures 2006",
"Tracy Pictures 2007",
"Tracy Pictures 2008",
"Tracy Pictures 2009",
"Tracy Pictures 2010",
"Tracy Pictures 2011",
"Tracy Pictures 2012",
"Tracy Pictures 2013 Jan-July",
"Tracy Pictures 2013 July- Dec",
"Tracy Pictures 2014",
"Tracy Pictures 2015",
"Tracy Took The Kids 2006",
"Tracy's Bday 2012",
"Tracy's Wedding 2002",
"Trip to Colorado 10 2002",
"Trip to Colorado June 2002",
"Tub 2002",
"Vericruz 2011"
]
}
}
}

458
Tests/appsettings.json Normal file
View File

@ -0,0 +1,458 @@
{
"Company": "Mike Phares",
"Linux": {},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Log4netProvider": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"MaxDegreeOfParallelism": 12,
"Serilog": {
"Using": [
"Serilog.Sinks.Console",
"Serilog.Sinks.File"
],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "Debug",
"Args": {
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
}
},
{
"Name": "Console",
"Args": {
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "%workingDirectory% - Log/log-.txt",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}",
"rollingInterval": "Hour"
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithThreadId"
],
"Properties": {
"Application": "Sample"
}
},
"WorkingDirectoryName": "PharesApps",
"Windows": {
"Configuration": {
"CheckJsonForDistanceResults": true,
"CrossDirectoryMaxItemsInDistanceCollection": 7,
"DateGroup": "2022-07-27",
"DistanceFactor": 8,
"FileNameDirectorySeparator": ".Z.",
"ForceMetadataLastWriteTimeToCreationTime": false,
"ForcePropertyLastWriteTimeToCreationTime": false,
"ForceResizeLastWriteTimeToCreationTime": false,
"LoadOrCreateThenSaveDirectoryDistanceResults": true,
"LoadOrCreateThenSaveDistanceResults": true,
"LoadOrCreateThenSaveImageFacesResults": true,
"LoadOrCreateThenSaveIndex": false,
"LocationConfidenceFactor": 2,
"MappedMaxIndex": 1034720,
"MaxImagesInDirectoryForTopLevelFirstPass": 50,
"MaxItemsInDistanceCollection": 50,
"ModelDirectory": "C:/GitHub/dlib-models",
"ModelName": "Hog",
"NumJitters": 1,
"OutputExtension": ".jpg",
"OutputQuality": 95,
"OverrideForFaceImages": false,
"OverrideForFaceLandmarkImages": false,
"OverrideForResizeImages": false,
"PaddingLoops": 5,
"Pattern": "[^ABCDEFGHIJKLMNOPQRSTUVWXYZbcdfghjklmnpqrstvwxyz0-9]",
"PopulatePropertyId": true,
"PredictorModelName": "Large",
"PropertiesChangedForDistance": false,
"PropertiesChangedForFaces": false,
"PropertiesChangedForIndex": false,
"PropertiesChangedForMetadata": false,
"PropertiesChangedForProperty": false,
"PropertiesChangedForResize": false,
"Reverse": false,
"RootDirectory": "D:/Images",
"SaveFullYearOfRandomFiles": true,
"SaveResizedSubFiles": true,
"SaveShortcuts": true,
"SkipSearch": false,
"TestDistanceResults": true,
"WriteBitmapDataBytes": false,
"IgnoreExtensions": [
".gif",
".GIF"
],
"OutputResolutions": [
"176 x 176",
"256 x 256",
"353 x 353",
"1024 x 768",
"1920 x 1080"
],
"PropertyContentCollectionFiles": [],
"SaveFaceLandmarkForOutputResolutions": [
"176 x 176",
"256 x 256"
],
"ValidImageFormatExtensions": [
".bmp",
".BMP",
".gif",
".GIF",
".jpeg",
".JPEG",
".jpg",
".JPG",
".png",
".PNG",
".tiff",
".TIFF"
],
"ValidMetadataExtensions": [
".3gp",
".3GP",
".amr",
".AMR",
".avi",
".AVI",
".bmp",
".BMP",
".gif",
".GIF",
".ico",
".ICO",
".jpeg",
".JPEG",
".jpg",
".JPG",
".m4v",
".M4V",
".mov",
".MOV",
".mp4",
".MP4",
".mta",
".MTA",
".png",
".PNG",
".tiff",
".TIFF"
],
"ValidResolutions": [
"176 x 176",
"256 x 256",
"353 x 353",
"1024 x 768",
"1280 x 720",
"1280 x 800",
"1376 x 768",
"1600 x 1200",
"1920 x 1080",
"2256 x 1496",
"3840 x 2160",
"7680 x 4320"
],
"VerifyToSeason": [
". 2000",
". 2001",
". 2002",
". 2003",
". 2004",
". 2005",
". 2006",
". 2007",
". 2008",
". 2009",
". 2010",
". 2011",
". 2012",
". 2013",
". 2014",
". 2015",
". 2016",
". 2017",
". 2018",
". 2019",
". 2020",
". 2021",
". 2022",
". 2023",
". 2024",
". 2025",
". 2026",
". 2027",
". 2028",
". 2029",
"=2000.0 Winter",
"=2002.1 Spring",
"=2002.4 Winter",
"=2003.0 Winter",
"=2003.1 Spring",
"=2003.3 Fall",
"=2003.4 Winter",
"=2004.0 Winter",
"=2005.1 Spring",
"=2005.2 Summer",
"=2005.3 Fall",
"=2005.4 Winter",
"=2006.0 Winter",
"=2006.1 Spring",
"=2006.3 Fall",
"=2007.0 Winter",
"=2007.2 Summer Logan Michael",
"=2007.2 Summer",
"=2007.3 Fall Logan Michael",
"=2007.4 Winter Logan Michael",
"=2008.0 Winter Logan Michael",
"=2008.1 Spring Logan Michael",
"=2008.2 Summer Logan Michael",
"=2008.2 Summer",
"=2008.3 Fall Logan Michael",
"=2009.0 Winter Logan Michael",
"=2009.0 Winter",
"=2009.1 Spring Logan Michael",
"=2009.1 Spring",
"=2009.2 Summer Logan Michael",
"=2009.2 Summer",
"=2009.3 Fall Logan Michael",
"=2009.3 Fall",
"=2009.4 Winter Logan Michael",
"=2009.4 Winter",
"=2010.0 Winter Logan Michael",
"=2010.0 Winter",
"=2010.1 Spring Logan Michael",
"=2010.1 Spring",
"=2010.2 Summer",
"=2010.3 Fall Logan Michael",
"=2010.3 Fall",
"=2010.4 Winter",
"=2011.0 Winter",
"=2011.1 Spring",
"=2011.2 Summer",
"=2011.3 Fall",
"=2011.4 Winter",
"=2012.0 Winter Chelsea 2012",
"=2012.0 Winter Chelsea",
"=2012.0 Winter",
"=2012.1 Spring Chelsea",
"=2012.1 Spring",
"=2012.2 Summer Chelsea",
"=2012.2 Summer",
"=2012.3 Fall Chelsea",
"=2012.3 Fall",
"=2012.4 Winter Chelsea",
"=2012.4 Winter",
"=2013.0 Winter Chelsea 2013",
"=2013.0 Winter Chelsea",
"=2013.0 Winter",
"=2013.1 Spring",
"=2013.2 Summer Chelsea",
"=2013.2 Summer",
"=2013.3 Fall Chelsea",
"=2013.3 Fall",
"=2013.4 Winter",
"=2014.0 Winter",
"=2014.1 Spring",
"=2014.2 Summer",
"=2014.3 Fall",
"=2014.4 Winter",
"=2015.0 Winter",
"=2015.1 Spring",
"=2015.2 Summer",
"=2015.3 Fall",
"=2015.4 Winter",
"=2016.0 Winter",
"=2016.1 Spring",
"=2016.2 Summer",
"=2016.3 Fall",
"=2016.4 Winter",
"=2017.1 Spring",
"=2017.2 Summer",
"=2017.3 Fall",
"=2017.4 Winter",
"=2018.0 Winter",
"=2018.1 Spring",
"=2018.3 Fall",
"=2018.4 Winter",
"=2019.0 Winter",
"=2019.1 Spring",
"=2019.2 Summer",
"=2019.3 Fall",
"=2019.4 Winter",
"=2020.0 Winter",
"=2020.1 Spring",
"=2020.2 Summer",
"=2020.3 Fall",
"=2020.4 Winter",
"=2021.1 Spring",
"=2021.2 Summer",
"=2021.3 Fall",
"=2021.4 Winter",
"=2022.0 Winter",
"=2022.1 Spring",
"Anthem 2015",
"April 2010",
"April 2013",
"December 2006",
"December 2010",
"Fall 2005",
"Fall 2015",
"Fall 2016",
"Fall 2017",
"Fall 2018",
"Fall 2019",
"Fall 2020",
"Fall 2021",
"February 2010",
"January 2015",
"July 2010",
"June 2010",
"Kids 2005",
"March 2013",
"May 2010",
"May 2011",
"May 2013",
"October 2005",
"October 2014",
"Spring 2013",
"Spring 2014",
"Spring 2016",
"Spring 2018",
"Spring 2019",
"Spring 2020",
"Summer 2011",
"Summer 2012",
"Summer 2013",
"Summer 2014",
"Summer 2015",
"Summer 2016",
"Summer 2017",
"Summer 2018",
"Summer 2020",
"Summer 2021",
"Winter 2015",
"Winter 2016",
"Winter 2017",
"Winter 2018",
"Winter 2019-2020",
"Winter 2020",
"zzz =2005.0 Winter Tracy Pictures",
"zzz =2005.1 Spring Tracy Pictures",
"zzz =2005.2 Summer Tracy Pictures",
"zzz =2005.3 Fall Tracy Pictures",
"zzz =2005.4 Winter Tracy Pictures",
"zzz =2006.1 Spring Tracy Pictures",
"zzz =2007.0 Winter Tracy Pictures",
"zzz =2007.2 Summer Tracy Pictures",
"zzz =2008.0 Winter Tracy Pictures",
"zzz =2008.2 Summer Tracy Pictures",
"zzz =2009.0 Winter Tracy Pictures",
"zzz =2009.2 Summer Tracy Pictures",
"zzz =2009.3 Fall Tracy Pictures",
"zzz =2009.4 Winter Tracy Pictures",
"zzz =2010.0 Winter Tracy Pictures",
"zzz =2010.1 Spring Tracy Pictures",
"zzz =2010.2 Summer Tracy Pictures",
"zzz =2010.3 Fall Tracy Pictures",
"zzz =2011.0 Winter Tracy Pictures",
"zzz =2011.1 Spring Tracy Pictures",
"zzz =2011.2 Summer Tracy Pictures",
"zzz =2011.3 Fall Tracy Pictures",
"zzz =2011.4 Winter Tracy Pictures",
"zzz =2012.0 Winter Tracy Pictures",
"zzz =2012.1 Spring Tracy Pictures",
"zzz =2012.2 Summer Tracy Pictures",
"zzz =2012.3 Fall Tracy Pictures",
"zzz =2012.4 Winter Tracy Pictures",
"zzz =2013.0 Winter Tracy Pictures",
"zzz =2013.1 Spring Tracy Pictures",
"zzz =2013.2 Summer Tracy Pictures",
"zzz =2013.3 Fall Tracy Pictures",
"zzz =2013.4 Winter Tracy Pictures",
"zzz =2014.0 Winter Tracy Pictures",
"zzz =2014.1 Spring Tracy Pictures",
"zzz =2014.2 Summer Tracy Pictures",
"zzz =2014.3 Fall Tracy Pictures",
"zzz =2014.4 Winter Tracy Pictures",
"zzz =2015.0 Winter Tracy Pictures"
],
"MixedYearRelativePaths": [
"Edited",
"Phares Slides",
"Rex Memorial",
"Scanned Grandma's Quilt",
"Scanned Pictures Of Kids",
"Scanned Prints",
"Slide in Name Order Originals (622)",
"Slides Pictures"
],
"IgnoreRelativePaths": [
"3757 W Whitman 2017",
"501 Playful Meadows 2006",
"501 Playful Meadows 2007",
"501 Playful Meadows 2008",
"501 Playful Meadows 2009",
"501 Playful Meadows 2010",
"501 Playful Meadows 2013",
"501 Playful Meadows 2015",
"6309 Evesham 2003",
"6309 Evesham 2004",
"Crystal's Wedding 2003",
"Danny's Wedding 2009",
"Door images 2019",
"Family Pictures 2006",
"Family Pictures 2007",
"Family Pictures 2011",
"Family Pictures 2013",
"GrandPrix 2004",
"Kids School Pictures 2004",
"Kristy 2002",
"Kristy Parents Wedding 2005",
"Logan Ultrasound 2007",
"Mandy's Dogs 2008",
"Motorcycles 2010",
"Motorcycles 2013",
"Motorcycles 2014",
"Phares Slides",
"Portrait Innovations April 2008",
"Portrait Innovations December 2007",
"Portrait Innovations June 2008",
"Portrait Innovations March 2012",
"The guys house 2000",
"Tracy Pictures 2005",
"Tracy Pictures 2006",
"Tracy Pictures 2007",
"Tracy Pictures 2008",
"Tracy Pictures 2009",
"Tracy Pictures 2010",
"Tracy Pictures 2011",
"Tracy Pictures 2012",
"Tracy Pictures 2013 Jan-July",
"Tracy Pictures 2013 July- Dec",
"Tracy Pictures 2014",
"Tracy Pictures 2015",
"Tracy Took The Kids 2006",
"Tracy's Bday 2012",
"Tracy's Wedding 2002",
"Trip to Colorado 10 2002",
"Trip to Colorado June 2002",
"Tub 2002",
"Vericruz 2011"
]
}
}
}

View File

@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Resize", "Resize\Resize.csp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Instance", "Instance\Instance.csproj", "{75D4A1EA-3727-4E28-9E87-FC1C77164ECD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{B4FB6B43-36EC-404D-B934-5C695C6E32CC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -72,5 +74,9 @@ Global
{75D4A1EA-3727-4E28-9E87-FC1C77164ECD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75D4A1EA-3727-4E28-9E87-FC1C77164ECD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75D4A1EA-3727-4E28-9E87-FC1C77164ECD}.Release|Any CPU.Build.0 = Release|Any CPU
{B4FB6B43-36EC-404D-B934-5C695C6E32CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B4FB6B43-36EC-404D-B934-5C695C6E32CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4FB6B43-36EC-404D-B934-5C695C6E32CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4FB6B43-36EC-404D-B934-5C695C6E32CC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -1,5 +1,7 @@
{
"scripts": {
"AmazonUsername": "phares36@gmail.com",
"AmazonPassword":"JlPhgtv@63",
"Alpha": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"build": "dotnet build --runtime win-x64 --self-contained",
"dotnet-format": "dotnet format --report .vscode --verbosity detailed --severity warn",