feat(metadata): parse TIFF/Exif, JPEG segments and MakerNotes
ExifParser walks IFD0, Exif, GPS and SubIFDs, selects the main raster (largest full-resolution IFD), and enumerates embedded JPEG previews (JPEGInterchangeFormat, single-strip/tile Compression 6/7, lossless raw strips excluded). JpegParser scans APP1 Exif/XMP/extended XMP, APP2 MPF large thumbnails and SOFn up to SOS, tolerating fill bytes and garbage. Vendor MakerNotes (Canon, Nikon, Sony, Fujifilm, Olympus/OM, Panasonic) fill serial, lens, shutter count, stabiliser, ISO and colour temperature only when standard tags did not. TiffTags gains GPSVersionID, GPSStatus, YCbCrPositioning, StandardOutputSensitivity and ISOSpeed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
11 files changed
+918
No files matched your search
@@ -0,0 +1,39 @@
|
||||
using System.Globalization;
|
||||
using Titano.Core.Metadata.Tiff;
|
||||
|
||||
namespace Titano.Core.Metadata.MakerNotes;
|
||||
|
||||
/// <summary>Canon MakerNote: a bare IFD whose offsets are relative to the enclosing TIFF header (also CR3 CMT3).</summary>
|
||||
internal static class CanonMakerNote
|
||||
{
|
||||
private const ushort CameraSettings = 0x0001;
|
||||
private const ushort SerialNumber = 0x000C;
|
||||
private const ushort LensModel = 0x0095;
|
||||
private const ushort InternalSerialNumber = 0x0096;
|
||||
private const ushort ColorTemperature = 0x00AE;
|
||||
private const int ImageStabilizationIndex = 34;
|
||||
|
||||
public static void Parse(TiffReader r, Ifd ifd, MetadataBuilder m)
|
||||
{
|
||||
var v = m.MakerNote;
|
||||
if (IfdValue.UInt(r, ifd, SerialNumber) is { } serial and > 0)
|
||||
{
|
||||
// Canon prints 6 digits on EOS-1D bodies and 10 elsewhere.
|
||||
var digits = m.Model?.Contains("EOS-1D", StringComparison.OrdinalIgnoreCase) == true ? "D6" : "D10";
|
||||
v.BodySerial ??= serial.ToString(digits, CultureInfo.InvariantCulture);
|
||||
}
|
||||
v.BodySerial ??= IfdValue.String(r, ifd, InternalSerialNumber);
|
||||
v.LensModel ??= IfdValue.String(r, ifd, LensModel);
|
||||
v.ColorTemperature ??= IfdValue.Int(r, ifd, ColorTemperature) is { } kelvin and > 0 and < 65535 ? kelvin : null;
|
||||
if (IfdValue.UInts(r, ifd, CameraSettings) is { Length: > ImageStabilizationIndex } settings)
|
||||
{
|
||||
// 0 Off, 1 On, 2 Shoot only, 3 Panning, 4 Dynamic; +256 for the "(2)" variants.
|
||||
v.ImageStabilization ??= (settings[ImageStabilizationIndex] & 0xFF) switch
|
||||
{
|
||||
0 => false,
|
||||
>= 1 and <= 4 => true,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user