Skip to content

Commit

Permalink
remove duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Nov 9, 2023
1 parent 08360a9 commit ec77434
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs
Original file line number Diff line number Diff line change
Expand Up @@ -961,9 +961,8 @@ private static string GetLocationPlaces(List<Directory> allExifItems, string ipt
return GetXmpData(xmpDirectory, xmpPropertyPath);
}

var locationCity = iptcDirectoryDirectory?.Tags.FirstOrDefault(
p => p.DirectoryName == "IPTC"
&& p.Name == iptcName)?.Description;
var locationCity = iptcDirectoryDirectory?.Tags
.FirstOrDefault(p => p.Name == iptcName)?.Description;
return locationCity;
}

Expand Down Expand Up @@ -1001,13 +1000,14 @@ private static double GetAperture(List<Directory> allExifItems)
{
var exifItem = allExifItems.OfType<ExifSubIfdDirectory>().FirstOrDefault();

// "Exif SubIFD"
var apertureString = exifItem?.Tags.FirstOrDefault(p =>
p.DirectoryName == "Exif SubIFD" && p.Name == "Aperture Value")?.Description;
p.Name == "Aperture Value")?.Description;

if (string.IsNullOrEmpty(apertureString))
{
apertureString = exifItem?.Tags.FirstOrDefault(p =>
p.DirectoryName == "Exif SubIFD" && p.Name == "F-Number")?.Description;
p.Name == "F-Number")?.Description;
}

// XMP,http://ns.adobe.com/exif/1.0/,exif:FNumber,9/1
Expand Down Expand Up @@ -1037,13 +1037,15 @@ private static string GetShutterSpeedValue(List<Directory> allExifItems)
{
var exifItem = allExifItems.OfType<ExifSubIfdDirectory>().FirstOrDefault();

// Exif SubIFD
var shutterSpeedString = exifItem?.Tags.FirstOrDefault(p =>
p.DirectoryName == "Exif SubIFD" && p.Name == "Shutter Speed Value")?.Description;
p.Name == "Shutter Speed Value")?.Description;

if (string.IsNullOrEmpty(shutterSpeedString))
{
// Exif SubIFD
shutterSpeedString = exifItem?.Tags.FirstOrDefault(p =>
p.DirectoryName == "Exif SubIFD" && p.Name == "Exposure Time")?.Description;
p.Name == "Exposure Time")?.Description;
}

// XMP,http://ns.adobe.com/exif/1.0/,exif:ExposureTime,1/20
Expand All @@ -1069,24 +1071,25 @@ private static int GetIsoSpeedValue(List<Directory> allExifItems)
{
var subIfdItem = allExifItems.OfType<ExifSubIfdDirectory>().FirstOrDefault();


// Exif SubIFD
var isoSpeedString = subIfdItem?.Tags.FirstOrDefault(p =>
p.DirectoryName == "Exif SubIFD" && p.Name == "ISO Speed Ratings")?.Description;
p.Name == "ISO Speed Ratings")?.Description;

if ( string.IsNullOrEmpty(isoSpeedString) )
{
var canonMakerNoteDirectory = allExifItems.OfType<CanonMakernoteDirectory>().FirstOrDefault();

// Canon Makernote
isoSpeedString = canonMakerNoteDirectory?.Tags.FirstOrDefault(p =>
p.DirectoryName == "Canon Makernote" && p.Name == "Iso")?.Description;
p.Name == "Iso")?.Description;
if ( isoSpeedString == "Auto" )
{
// src: https://github.com/exiftool/exiftool/blob/
// 6b994069d52302062b9d7a462dc27082c4196d95/lib/Image/ExifTool/Canon.pm#L8882
var autoIso = canonMakerNoteDirectory.Tags.FirstOrDefault(p =>
p.DirectoryName == "Canon Makernote" && p.Name == "Auto ISO")?.Description;
p.Name == "Auto ISO")?.Description;

Check warning on line 1090 in starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs

View check run for this annotation

Codecov / codecov/patch

starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs#L1090

Added line #L1090 was not covered by tests
var baseIso = canonMakerNoteDirectory.Tags.FirstOrDefault(p =>
p.DirectoryName == "Canon Makernote" && p.Name == "Base ISO")?.Description;
p.Name == "Base ISO")?.Description;

Check warning on line 1092 in starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs

View check run for this annotation

Codecov / codecov/patch

starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs#L1092

Added line #L1092 was not covered by tests
if ( !string.IsNullOrEmpty(autoIso) && !string.IsNullOrEmpty(baseIso) )
{
int.TryParse(autoIso, NumberStyles.Number,
Expand All @@ -1111,6 +1114,5 @@ private static int GetIsoSpeedValue(List<Directory> allExifItems)
int.TryParse(isoSpeedString, NumberStyles.Number, CultureInfo.InvariantCulture, out var isoSpeed);
return isoSpeed;
}

}
}

0 comments on commit ec77434

Please sign in to comment.