This commit is contained in:
2023-12-26 18:27:37 -07:00
parent c2c711673f
commit ec22446643
37 changed files with 1279 additions and 932 deletions

View File

@ -8,7 +8,6 @@ using System.Text;
using System.Text.RegularExpressions;
using View_by_Distance.Shared.Models;
using View_by_Distance.Shared.Models.Methods;
using View_by_Distance.Shared.Models.Stateless;
namespace View_by_Distance.Property.Models.Stateless;
@ -207,13 +206,12 @@ internal partial class Property
DateTime? dateTimeOriginal = null;
DateTime? dateTimeDigitized = null;
DateTime? dateTimeOriginalByLogic = null;
IReadOnlyList<MetadataExtractor.Directory> directories;
DateTime? dateTimeFromName = GetDateTimeFromName(fileHolder);
if (!isValidImageFormatExtension && fileHolder.Exists && metadata is not null)
{
try
{
directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(fileHolder.FullName);
IReadOnlyList<MetadataExtractor.Directory> directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(fileHolder.FullName);
(dateTimeOriginalByLogic, DateTime?[] metadataDateTimes) = metadata.GetDateTimes(fileHolder, directories);
dateTimesByLogic = GetDateTimes(metadataDateTimes);
message = null;
@ -244,9 +242,9 @@ internal partial class Property
id ??= Shared.Models.Stateless.Methods.IId.GetDeterministicHashCode(bytes);
}
dateTimeFormat = IProperty.DateTimeFormat();
if (image.PropertyIdList.Contains((int)IExif.Tags.DateTime))
if (image.PropertyIdList.Contains(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagDateTime))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.DateTime);
propertyItem = image.GetPropertyItem(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagDateTime);
if (propertyItem?.Value is not null)
{
value = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
@ -256,9 +254,9 @@ internal partial class Property
dateTime = checkDateTime;
}
}
if (image.PropertyIdList.Contains((int)IExif.Tags.DateTimeDigitized))
if (image.PropertyIdList.Contains(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagDateTimeDigitized))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.DateTimeDigitized);
propertyItem = image.GetPropertyItem(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagDateTimeDigitized);
if (propertyItem?.Value is not null)
{
value = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
@ -268,9 +266,9 @@ internal partial class Property
dateTimeDigitized = checkDateTime;
}
}
if (image.PropertyIdList.Contains((int)IExif.Tags.DateTimeOriginal))
if (image.PropertyIdList.Contains(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagDateTimeOriginal))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.DateTimeOriginal);
propertyItem = image.GetPropertyItem(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagDateTimeOriginal);
if (propertyItem?.Value is not null)
{
value = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
@ -280,9 +278,9 @@ internal partial class Property
dateTimeOriginal = checkDateTime;
}
}
if (image.PropertyIdList.Contains((int)IExif.Tags.GPSDateStamp))
if (image.PropertyIdList.Contains(MetadataExtractor.Formats.Exif.GpsDirectory.TagDateStamp))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.GPSDateStamp);
propertyItem = image.GetPropertyItem(MetadataExtractor.Formats.Exif.GpsDirectory.TagDateStamp);
if (propertyItem?.Value is not null)
{
value = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
@ -292,27 +290,27 @@ internal partial class Property
gpsDateStamp = checkDateTime;
}
}
if (image.PropertyIdList.Contains((int)IExif.Tags.Make))
if (image.PropertyIdList.Contains(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagMake))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.Make);
propertyItem = image.GetPropertyItem(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagMake);
if (propertyItem?.Value is not null)
make = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
}
if (image.PropertyIdList.Contains((int)IExif.Tags.Model))
if (image.PropertyIdList.Contains(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagModel))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.Model);
propertyItem = image.GetPropertyItem(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagModel);
if (propertyItem?.Value is not null)
model = asciiEncoding.GetString(propertyItem.Value, 0, propertyItem.Len - 1);
}
if (image.PropertyIdList.Contains((int)IExif.Tags.Orientation))
if (image.PropertyIdList.Contains(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagOrientation))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.Orientation);
propertyItem = image.GetPropertyItem(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagOrientation);
if (propertyItem?.Value is not null)
orientation = BitConverter.ToInt16(propertyItem.Value, 0);
}
if (image.PropertyIdList.Contains((int)IExif.Tags.XPKeywords))
if (image.PropertyIdList.Contains(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagWinKeywords))
{
propertyItem = image.GetPropertyItem((int)IExif.Tags.XPKeywords);
propertyItem = image.GetPropertyItem(MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagWinKeywords);
if (propertyItem?.Value is not null)
{
if (propertyItem.Type == 2)
@ -333,7 +331,7 @@ internal partial class Property
{
try
{
directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(fileHolder.FullName);
IReadOnlyList<MetadataExtractor.Directory> directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(fileHolder.FullName);
(dateTimeOriginalByLogic, DateTime?[] metadataDateTimes) = metadata.GetDateTimes(fileHolder, directories);
dateTimesByLogic = GetDateTimes(dateTimes, metadataDateTimes);
message = null;