Skip to content

Commit

Permalink
Added manual shooting mode value from Fujifilm raw tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Forget committed Dec 27, 2023
1 parent 55af80f commit 41803e1
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ private static void OutputFolderBadges(string folder, string assemblyLocation, O
private static void OutputBadge(string file, string assemblyLocation, Options options)
{
static TagLocator Locator(string directory, string tag) => new() { Directory = directory, Tag = tag };
static RawTagLocator RawLocator(string directory, Int32 tag) => new() { Directory = directory, Tag = tag };

try
{
Expand Down Expand Up @@ -418,6 +419,39 @@ private static void OutputBadge(string file, string assemblyLocation, Options op
Locator("Nikon Makernote", "Shooting Mode"),
Locator("Olympus Camera Settings", "Drive Mode"),
}) ?? "n/a";
if (shootingMode == "n/a" && camera == "GFX100S")
{
var driveMode = GetInt32Value(directories, new[] {
RawLocator("Fujifilm Makernote", 0x1103),
});
switch (driveMode)
{
case 0:
shootingMode = "Single";
break;
case 1:
shootingMode = "Continuous Low";
break;
case 2:
shootingMode = "Continuous High";
break;
}
var bracketing = GetStringValue(directories, new[]
{
Locator("Fujifilm Makernote", "Auto Bracketing"),
}) ?? "n/a";
if (bracketing != "n/a" && bracketing != "Off")
{
if (shootingMode == "n/a")
{
shootingMode = "Auto Bracketing";
}
else
{
shootingMode += ", Auto Bracketing";
}
}
}

var dateTimeOriginal = GetStringValue(directories, new[] {
Locator("Exif SubIFD", "Date/Time Original"),
Expand Down Expand Up @@ -957,6 +991,12 @@ class TagLocator
public string Tag { get; set; }
}

class RawTagLocator
{
public string Directory { get; set; }
public Int32 Tag { get; set; }
}

private static string GetStringValue(IEnumerable<MetadataExtractor.Directory> directories, IEnumerable<TagLocator> tagLocators)
{
foreach (var locator in tagLocators)
Expand All @@ -977,6 +1017,29 @@ private static string GetStringValue(IEnumerable<MetadataExtractor.Directory> di
return null;
}

private static int GetInt32Value(IEnumerable<MetadataExtractor.Directory> directories, IEnumerable<RawTagLocator> tagLocators)
{
foreach (var locator in tagLocators)
{
var locatedDirectories = directories.Where(directory => directory.Name == locator.Directory);
foreach (var directory in locatedDirectories)
{
if (directory != null)
{
try
{
return directory.GetInt32(locator.Tag);
}
catch
{
return int.MaxValue;
}
}
}
}
return int.MaxValue;
}

private static IPathCollection BuildCorners(int imageWidth, int imageHeight, float cornerRadius)
{
var rectHoriz = new RectangularPolygon(-0.5f, cornerRadius - 0.5f, imageWidth, imageHeight - cornerRadius * 2);
Expand Down

0 comments on commit 41803e1

Please sign in to comment.