Humanizer and File Name Extension Bug
This commit is contained in:
@ -20,11 +20,11 @@ public class D_Face
|
||||
|
||||
internal List<string> AngleBracketCollection { get; }
|
||||
|
||||
protected readonly string _FilenameExtension;
|
||||
public string FilenameExtension => _FilenameExtension;
|
||||
protected readonly string _FileNameExtension;
|
||||
public string FileNameExtension => _FileNameExtension;
|
||||
|
||||
protected readonly string _HiddenFilenameExtension;
|
||||
public string HiddenFilenameExtension => _HiddenFilenameExtension;
|
||||
protected readonly string _HiddenFileNameExtension;
|
||||
public string HiddenFileNameExtension => _HiddenFileNameExtension;
|
||||
|
||||
private readonly Model _Model;
|
||||
private readonly string _ArgZero;
|
||||
@ -38,7 +38,7 @@ public class D_Face
|
||||
private readonly EncoderParameters _HiddenEncoderParameters;
|
||||
private readonly JsonSerializerOptions _WriteIndentedAndWhenWritingNull;
|
||||
|
||||
internal D_Face(Configuration configuration, string argZero, Model model, ModelParameter modelParameter, PredictorModel predictorModel, ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension, ImageCodecInfo hiddenImageCodecInfo, EncoderParameters hiddenEncoderParameters, string hiddenFilenameExtension)
|
||||
internal D_Face(Configuration configuration, string argZero, Model model, ModelParameter modelParameter, PredictorModel predictorModel, ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension, ImageCodecInfo hiddenImageCodecInfo, EncoderParameters hiddenEncoderParameters, string hiddenFileNameExtension)
|
||||
{
|
||||
_Model = model;
|
||||
_ArgZero = argZero;
|
||||
@ -47,12 +47,12 @@ public class D_Face
|
||||
_ModelParameter = modelParameter;
|
||||
_PredictorModel = predictorModel;
|
||||
_EncoderParameters = encoderParameters;
|
||||
_FilenameExtension = filenameExtension;
|
||||
_FileNameExtension = filenameExtension;
|
||||
_Log = Serilog.Log.ForContext<D_Face>();
|
||||
AngleBracketCollection = new List<string>();
|
||||
_HiddenImageCodecInfo = hiddenImageCodecInfo;
|
||||
_HiddenEncoderParameters = hiddenEncoderParameters;
|
||||
_HiddenFilenameExtension = hiddenFilenameExtension;
|
||||
_HiddenFileNameExtension = hiddenFileNameExtension;
|
||||
_WriteIndentedAndWhenWritingNull = new JsonSerializerOptions { WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull };
|
||||
}
|
||||
|
||||
@ -148,9 +148,9 @@ public class D_Face
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
Bitmap bitmap;
|
||||
Graphics graphics;
|
||||
Location? location;
|
||||
Bitmap preRotated;
|
||||
Rectangle rectangle;
|
||||
using Bitmap source = new(resizedFileHolder.FullName);
|
||||
foreach ((Face face, FileInfo? fileInfo, string fileName) in collection)
|
||||
@ -165,11 +165,11 @@ public class D_Face
|
||||
width = location.Right - location.Left;
|
||||
height = location.Bottom - location.Top;
|
||||
rectangle = new Rectangle(location.Left, location.Top, width, height);
|
||||
using (preRotated = new(width, height))
|
||||
using (bitmap = new(width, height))
|
||||
{
|
||||
using (graphics = Graphics.FromImage(preRotated))
|
||||
using (graphics = Graphics.FromImage(bitmap))
|
||||
graphics.DrawImage(source, new Rectangle(0, 0, width, height), rectangle, GraphicsUnit.Pixel);
|
||||
preRotated.Save(fileInfo.FullName, _ImageCodecInfo, _EncoderParameters);
|
||||
bitmap.Save(fileInfo.FullName, _ImageCodecInfo, _EncoderParameters);
|
||||
}
|
||||
if (File.Exists(fileName))
|
||||
File.Delete(fileName);
|
||||
@ -179,11 +179,11 @@ public class D_Face
|
||||
width = location.Right - location.Left;
|
||||
height = location.Bottom - location.Top;
|
||||
rectangle = new Rectangle(location.Left, location.Top, width, height);
|
||||
using (preRotated = new(width, height))
|
||||
using (bitmap = new(width, height))
|
||||
{
|
||||
using (graphics = Graphics.FromImage(preRotated))
|
||||
using (graphics = Graphics.FromImage(bitmap))
|
||||
graphics.DrawImage(source, new Rectangle(0, 0, width, height), rectangle, GraphicsUnit.Pixel);
|
||||
preRotated.Save(fileName, _HiddenImageCodecInfo, _HiddenEncoderParameters);
|
||||
bitmap.Save(fileName, _HiddenImageCodecInfo, _HiddenEncoderParameters);
|
||||
}
|
||||
File.SetAttributes(fileName, FileAttributes.Hidden);
|
||||
}
|
||||
@ -374,7 +374,7 @@ public class D_Face
|
||||
continue;
|
||||
}
|
||||
deterministicHashCodeKeyDisplay = Shared.Models.Stateless.Methods.IMapping.GetDeterministicHashCodeKey(item.Property.Id.Value, face.Location.NormalizedPixelPercentage.Value);
|
||||
fileInfo = new FileInfo(Path.Combine(facesDirectory, $"{deterministicHashCodeKeyDisplay}{item.ImageFileHolder.ExtensionLowered}{_FilenameExtension}"));
|
||||
fileInfo = new FileInfo(Path.Combine(facesDirectory, $"{deterministicHashCodeKeyDisplay}{item.ImageFileHolder.ExtensionLowered}{_FileNameExtension}"));
|
||||
if (!fileInfo.Exists)
|
||||
{
|
||||
if (fileInfo.Directory?.Parent is null)
|
||||
@ -383,7 +383,7 @@ public class D_Face
|
||||
if (File.Exists(parentCheck))
|
||||
File.Delete(parentCheck);
|
||||
}
|
||||
collection.Add(new(face, fileInfo, Path.Combine(facesDirectory, $"{deterministicHashCodeKeyDisplay}{item.ImageFileHolder.ExtensionLowered}{_HiddenFilenameExtension}")));
|
||||
collection.Add(new(face, fileInfo, Path.Combine(facesDirectory, $"{deterministicHashCodeKeyDisplay}{item.ImageFileHolder.ExtensionLowered}{_HiddenFileNameExtension}")));
|
||||
if (_Configuration.OverrideForFaceImages)
|
||||
check = true;
|
||||
else if (!fileInfo.Exists)
|
||||
|
||||
Reference in New Issue
Block a user