Skip to content

Commit

Permalink
Added AF mode and shooting mode to badge
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Forget committed Dec 14, 2023
1 parent df36bab commit daa8b80
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 12 deletions.
71 changes: 59 additions & 12 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using SixLabors.Fonts;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using MetadataExtractor;
//using MetadataExtractor.Formats;

namespace ImageDetailsCore
{
Expand Down Expand Up @@ -245,17 +247,17 @@ static void Main(string[] args)
{
waitingForOutput = false;
options.Output = arg;
if (!Directory.Exists(options.Output))
if (!System.IO.Directory.Exists(options.Output))
{
Directory.CreateDirectory(options.Output);
System.IO.Directory.CreateDirectory(options.Output);
}
Console.WriteLine("Set output location to: {0}", options.Output);
}
else if (File.Exists(arg))
{
OutputBadge(arg, location, options);
}
else if (Directory.Exists(arg))
else if (System.IO.Directory.Exists(arg))
{
OutputFolderBadges(arg, location, options);
}
Expand Down Expand Up @@ -286,7 +288,7 @@ private static Options ReadOptions(string optionsFileName, string location)
private static void OutputFolderBadges(string folder, string assemblyLocation, Options options)
{
var searchOptions = options.RecursiveFolders ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
foreach (var file in Directory.GetFiles(folder, "*.*", searchOptions).Order())
foreach (var file in System.IO.Directory.GetFiles(folder, "*.*", searchOptions).Order())
{
if (options.FolderSearchExtensions.Any(extension => string.Equals(System.IO.Path.GetExtension(file), extension, StringComparison.OrdinalIgnoreCase)))
{
Expand All @@ -309,6 +311,33 @@ private static void OutputBadge(string file, string assemblyLocation, Options op
foreach (var tag in directory.Tags)
{
Console.WriteLine($"{directory.Name} - {tag.Name} (0x{tag.Type:x4}) = {tag.Description}");
//if (directory.Name == "Exif SubIFD" && tag.Name == "Makernote")
//{
// var byteArray = directory.GetByteArray(tag.Type);
// if (byteArray != null)
// {
// const int rowSize = 32;
// for (var index = 0; index < byteArray.Length; index += rowSize)
// {
// var hexPad = "";
// var charPad = "";
// for (var byteIndex = 0; byteIndex < rowSize; byteIndex++)
// {
// if (index + byteIndex < byteArray.Length)
// {
// hexPad += byteArray[index + byteIndex].ToString("x2") + " ";
// charPad += char.IsControl((char)byteArray[index + byteIndex]) ? "." : (char)byteArray[index + byteIndex];
// }
// else
// {
// hexPad += " ";
// charPad += " ";
// }
// }
// Console.WriteLine("\t{0} - {1}", hexPad, charPad);
// }
// }
//}
}
}
}
Expand Down Expand Up @@ -376,6 +405,15 @@ private static void OutputBadge(string file, string assemblyLocation, Options op
Locator("Exif SubIFD", "White Balance"),
}) ?? "n/a";

var afMode = GetStringValue(directories, new[] {
Locator("Nikon Makernote", "AF Type"),
Locator("Fujifilm Makernote", "Focus Mode"),
}) ?? "n/a";

var shootingMode = GetStringValue(directories, new[] {
Locator("Nikon Makernote", "Shooting Mode"),
}) ?? "n/a";

var dateTimeOriginal = GetStringValue(directories, new[] {
Locator("Exif SubIFD", "Date/Time Original"),
}) ?? "n/a";
Expand Down Expand Up @@ -705,25 +743,34 @@ private static void OutputBadge(string file, string assemblyLocation, Options op
imageContext = DrawValue(imageContext, drawingScale, 14, 32, 28, 33, System.IO.Path.Combine(imageLocation, @"camera.png"), "CAMERA", camera, FontStyle.Bold, theme.CameraForegroundColor, theme.LabelColor);

// Draw the lens
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 28, 78, System.IO.Path.Combine(imageLocation, @"lens.png"), "LENS", lens, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 28, 73, System.IO.Path.Combine(imageLocation, @"lens.png"), "LENS", lens, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);

// Draw the focal length
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 28, 118, System.IO.Path.Combine(imageLocation, @"ruler.png"), "FOCAL LENGTH", focalLength, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 28, 106, System.IO.Path.Combine(imageLocation, @"ruler.png"), "FOCAL LENGTH", focalLength, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);

// Draw the ISO
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 240, 118, System.IO.Path.Combine(imageLocation, @"film.png"), "ISO", iso, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 220, 106, System.IO.Path.Combine(imageLocation, @"film.png"), "ISO", iso, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);

// Draw the exposure
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 28, 158, System.IO.Path.Combine(imageLocation, @"aperture.png"), "EXPOSURE", string.Format("{0} @ {1}", shutterSpeed, aperture), FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 28, 139, System.IO.Path.Combine(imageLocation, @"aperture.png"), "EXPOSURE", string.Format("{0} @ {1}", shutterSpeed, aperture), FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);

// Draw the exposure bias
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 240, 158, System.IO.Path.Combine(imageLocation, @"bias.png"), "EXPOSURE BIAS", exposureBias, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 220, 139, System.IO.Path.Combine(imageLocation, @"bias.png"), "EXPOSURE BIAS", exposureBias, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);

// Draw the white balance
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 28, 198, System.IO.Path.Combine(imageLocation, @"whitebalance.png"), "WHITE BALANCE", whiteBalance, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 28, 172, System.IO.Path.Combine(imageLocation, @"whitebalance.png"), "WHITE BALANCE", whiteBalance, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);

// Draw the exposure program
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 240, 198, System.IO.Path.Combine(imageLocation, @"exposure.png"), "EXPOSURE PROGRAM", exposureProgram, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 220, 172, System.IO.Path.Combine(imageLocation, @"exposure.png"), "EXPOSURE PROGRAM", exposureProgram, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);

// Draw the AF mode
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 28, 205, System.IO.Path.Combine(imageLocation, @"focus.png"), "FOCUS MODE", afMode, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);

if (shootingMode != "n/a")
{
// Draw the Shooting mode
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 220, 205, System.IO.Path.Combine(imageLocation, @"shutter.png"), "SHOOTING MODE", shootingMode, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);
}

if (options.SkipDate)
{
Expand All @@ -736,7 +783,7 @@ private static void OutputBadge(string file, string assemblyLocation, Options op
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 28, 238, System.IO.Path.Combine(imageLocation, @"calendar.png"), "DATE", dateTimeOriginal, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);

// Draw the time
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 240, 238, System.IO.Path.Combine(imageLocation, @"artist.png"), "ARTIST", artist, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);
imageContext = DrawValue(imageContext, drawingScale, 11, 28, 220, 238, System.IO.Path.Combine(imageLocation, @"artist.png"), "ARTIST", artist, FontStyle.Regular, theme.ForegroundColor, theme.LabelColor);
}
});
var output = System.IO.Path.Combine(options.Output ?? System.IO.Path.GetDirectoryName(file), System.IO.Path.GetFileNameWithoutExtension(file) + "_info.png");
Expand Down
Binary file added Resources/Themes/black/focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Themes/black/shutter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Themes/dark/focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Themes/dark/shutter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Themes/light/focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Themes/light/shutter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Themes/white/focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Themes/white/shutter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit daa8b80

Please sign in to comment.