Back to using BlurHasher but not linked yet
This commit is contained in:
@ -23,6 +23,8 @@ namespace View_by_Distance.Instance;
|
||||
public partial class DlibDotNet
|
||||
{
|
||||
|
||||
private IBlurHasher? _BlurHasher;
|
||||
|
||||
private readonly D_Face _Faces;
|
||||
private readonly C_Resize _Resize;
|
||||
private readonly F_Random _Random;
|
||||
@ -32,7 +34,6 @@ public partial class DlibDotNet
|
||||
private readonly D2_FaceParts _FaceParts;
|
||||
private readonly AppSettings _AppSettings;
|
||||
private readonly List<string> _Exceptions;
|
||||
private readonly IThumbHasher _IThumbHasher;
|
||||
private readonly IsEnvironment _IsEnvironment;
|
||||
private readonly bool _PropertyRootExistedBefore;
|
||||
private readonly Models.Configuration _Configuration;
|
||||
@ -52,13 +53,13 @@ public partial class DlibDotNet
|
||||
IConsole console)
|
||||
{
|
||||
string message;
|
||||
_BlurHasher = null;
|
||||
_Console = console;
|
||||
_AppSettings = appSettings;
|
||||
_IsEnvironment = isEnvironment;
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
_Exceptions = new List<string>();
|
||||
_Log = Serilog.Log.ForContext<DlibDotNet>();
|
||||
_IThumbHasher = new ThumbHash.Models.C2_ThumbHasher();
|
||||
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||
Models.Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||
_Log.Information(propertyConfiguration.RootDirectory);
|
||||
@ -354,7 +355,6 @@ public partial class DlibDotNet
|
||||
MapLogic mapLogic,
|
||||
string outputResolution,
|
||||
string cResultsFullGroupDirectory,
|
||||
string c2ResultsFullGroupDirectory,
|
||||
string dResultsFullGroupDirectory,
|
||||
List<Tuple<string, DateTime>> sourceDirectoryChanges,
|
||||
Dictionary<string, List<MappingFromPhotoPrism>> fileNameToCollection,
|
||||
@ -378,31 +378,28 @@ public partial class DlibDotNet
|
||||
FileHolder resizedFileHolder = _Resize.GetResizedFileHolder(item);
|
||||
if (item.Property is not null && item.Property.Id is not null && resizedFileHolder.Exists && item.Property.Width is not null && item.Property.Height is not null)
|
||||
{
|
||||
string fileName;
|
||||
string c2ThumbHasherContentDirectory = Path.Combine(c2ResultsFullGroupDirectory, "()");
|
||||
string c2ThumbHasherSingletonDirectory = Path.Combine(c2ResultsFullGroupDirectory, "{}");
|
||||
if (!Directory.Exists(c2ThumbHasherContentDirectory))
|
||||
_ = Directory.CreateDirectory(c2ThumbHasherContentDirectory);
|
||||
if (!Directory.Exists(c2ThumbHasherSingletonDirectory))
|
||||
_ = Directory.CreateDirectory(c2ThumbHasherSingletonDirectory);
|
||||
MemoryStream memoryStream = _IThumbHasher.GetMemoryStream(Array.Empty<byte>(), item.Property.Width.Value, item.Property.Height.Value);
|
||||
string thumbHashJson = JsonSerializer.Serialize(Array.Empty<byte>())[1..^1];
|
||||
if (!Regex.Matches(thumbHashJson, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]").Any())
|
||||
fileName = Path.Combine(c2ThumbHasherSingletonDirectory, $"{thumbHashJson}.png");
|
||||
else
|
||||
{
|
||||
// string thumbHash = BitConverter.ToString(Array.Empty<byte>()).Replace("-", string.Empty);
|
||||
// fileName = Path.Combine(c2ThumbHasherContentDirectory, $"{thumbHash}.png");
|
||||
fileName = Path.Combine(c2ThumbHasherContentDirectory, $"{resizedFileHolder.NameWithoutExtension}.png");
|
||||
}
|
||||
if (!File.Exists(fileName))
|
||||
{
|
||||
using FileStream fileStream = new(fileName, FileMode.CreateNew);
|
||||
memoryStream.WriteTo(fileStream);
|
||||
memoryStream.Dispose();
|
||||
if (resizedFileHolder.LastWriteTime is not null)
|
||||
File.SetLastWriteTime(fileName, resizedFileHolder.LastWriteTime.Value);
|
||||
}
|
||||
_ = _BlurHasher?.EncodeAndSave(resizedFileHolder);
|
||||
// if (item.Property.Width.Value < -255 && item.Property.Height.Value < -255)
|
||||
// {
|
||||
// MemoryStream memoryStream = _ThumbHasher.GetMemoryStream(Array.Empty<byte>(), item.Property.Width.Value, item.Property.Height.Value);
|
||||
// string thumbHashJson = JsonSerializer.Serialize(Array.Empty<byte>())[1..^1];
|
||||
// if (!Regex.Matches(thumbHashJson, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]").Any())
|
||||
// fileName = Path.Combine(c2HasherSingletonDirectory, $"{thumbHashJson}.png");
|
||||
// else
|
||||
// {
|
||||
// // string thumbHash = BitConverter.ToString(Array.Empty<byte>()).Replace("-", string.Empty);
|
||||
// // fileName = Path.Combine(c2HasherContentDirectory, $"{thumbHash}.png");
|
||||
// fileName = Path.Combine(c2HasherContentDirectory, $"{resizedFileHolder.NameWithoutExtension}.png");
|
||||
// }
|
||||
// if (!File.Exists(fileName))
|
||||
// {
|
||||
// using FileStream fileStream = new(fileName, FileMode.CreateNew);
|
||||
// memoryStream.WriteTo(fileStream);
|
||||
// memoryStream.Dispose();
|
||||
// if (resizedFileHolder.LastWriteTime is not null)
|
||||
// File.SetLastWriteTime(fileName, resizedFileHolder.LastWriteTime.Value);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
if (item.Property is not null && item.Property.Id is not null && !item.Any())
|
||||
{
|
||||
@ -510,7 +507,6 @@ public partial class DlibDotNet
|
||||
MapLogic mapLogic,
|
||||
string outputResolution,
|
||||
string cResultsFullGroupDirectory,
|
||||
string c2ResultsFullGroupDirectory,
|
||||
string dResultsFullGroupDirectory,
|
||||
string d2ResultsFullGroupDirectory,
|
||||
List<Tuple<string, DateTime>> sourceDirectoryChanges,
|
||||
@ -540,7 +536,6 @@ public partial class DlibDotNet
|
||||
mapLogic,
|
||||
outputResolution,
|
||||
cResultsFullGroupDirectory,
|
||||
c2ResultsFullGroupDirectory,
|
||||
dResultsFullGroupDirectory,
|
||||
sourceDirectoryChanges,
|
||||
fileNameToCollection,
|
||||
@ -630,7 +625,7 @@ public partial class DlibDotNet
|
||||
includePredictorModel: false);
|
||||
string c2ResultsFullGroupDirectory = Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(
|
||||
_Configuration.PropertyConfiguration,
|
||||
nameof(ThumbHash.Models.C2_ThumbHasher),
|
||||
nameof(BlurHash.Models.C2_BlurHasher),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: false,
|
||||
@ -675,6 +670,7 @@ public partial class DlibDotNet
|
||||
{
|
||||
total = 0;
|
||||
(cResultsFullGroupDirectory, c2ResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory) = GetResultsFullGroupDirectories(outputResolution);
|
||||
_BlurHasher = new BlurHash.Models.C2_BlurHasher(_Configuration.PropertyConfiguration.ResultAllInOne, c2ResultsFullGroupDirectory);
|
||||
for (int i = 0; i < containers.Length; i++)
|
||||
{
|
||||
container = containers[i];
|
||||
@ -702,7 +698,6 @@ public partial class DlibDotNet
|
||||
mapLogic,
|
||||
outputResolution,
|
||||
cResultsFullGroupDirectory,
|
||||
c2ResultsFullGroupDirectory,
|
||||
dResultsFullGroupDirectory,
|
||||
d2ResultsFullGroupDirectory,
|
||||
sourceDirectoryChanges,
|
||||
|
Reference in New Issue
Block a user