Skip to content

Support additional Exif tags #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions MetadataExtractor/Formats/Exif/ExifDescriptorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public abstract class ExifDescriptorBase<T>(T directory)
TagInteropVersion => GetInteropVersionDescription(),
TagOrientation => GetOrientationDescription(),
TagResolutionUnit => GetResolutionDescription(),
TagTemperature => GetTemperatureDescription(),
TagHumidity => GetHumidityDescription(),
TagPressure => GetPressureDescription(),
TagWaterDepth => GetWaterDepthDescription(),
TagAcceleration => GetAccelerationDescription(),
TagCameraElevationAngle => GetCameraElevationAngleDescription(),
TagYCbCrPositioning => GetYCbCrPositioningDescription(),
TagXResolution => GetXResolutionDescription(),
TagYResolution => GetYResolutionDescription(),
Expand Down Expand Up @@ -164,6 +170,60 @@ public abstract class ExifDescriptorBase<T>(T directory)
"cm");
}

public string? GetTemperatureDescription()
{
if (!Directory.TryGetRational(TagTemperature, out Rational value))
return null;
if (value.Denominator == 0xFFFFFFFFL)
return "Unknown";
return $"{value.ToDouble():0.0} �C";
}

public string? GetHumidityDescription()
{
if (!Directory.TryGetRational(TagHumidity, out Rational value))
return null;
if (value.Denominator == 0xFFFFFFFFL)
return "Unknown";
return $"{value.ToDouble():0.0} %";
}

public string? GetPressureDescription()
{
if (!Directory.TryGetRational(TagPressure, out Rational value))
return null;
if (value.Denominator == 0xFFFFFFFFL)
return "Unknown";
return $"{value.ToDouble():0.0} hPa";
}

public string? GetWaterDepthDescription()
{
if (!Directory.TryGetRational(TagWaterDepth, out Rational value))
return null;
if (value.Denominator == 0xFFFFFFFFL)
return "Unknown";
return $"{value.ToDouble():0.0##} metres";
}

public string? GetAccelerationDescription()
{
if (!Directory.TryGetRational(TagAcceleration, out Rational value))
return null;
if (value.Denominator == 0xFFFFFFFFL)
return "Unknown";
return $"{value.ToDouble():0.0##} mGal";
}

public string? GetCameraElevationAngleDescription()
{
if (!Directory.TryGetRational(TagCameraElevationAngle, out Rational value))
return null;
if (value.Denominator == 0xFFFFFFFFL)
return "Unknown";
return $"{value.ToDouble():0.##} degrees";
}

/// <summary>The Windows specific tags uses plain Unicode.</summary>
private string? GetUnicodeDescription(int tag)
{
Expand Down
13 changes: 13 additions & 0 deletions MetadataExtractor/Formats/Exif/ExifDirectoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,13 @@ public abstract class ExifDirectoryBase : Directory

public const int TagSubsecondTimeDigitized = 0x9292;

public const int TagTemperature = 0x9400;
public const int TagHumidity = 0x9401;
public const int TagPressure = 0x9402;
public const int TagWaterDepth = 0x9403;
public const int TagAcceleration = 0x9404;
public const int TagCameraElevationAngle = 0x9405;

/// <summary>The image title, as used by Windows XP.</summary>
public const int TagWinTitle = 0x9C9B;

Expand Down Expand Up @@ -862,6 +869,12 @@ protected static void AddExifTagNames(Dictionary<int, string> map)
map[TagSubsecondTime] = "Sub-Sec Time";
map[TagSubsecondTimeOriginal] = "Sub-Sec Time Original";
map[TagSubsecondTimeDigitized] = "Sub-Sec Time Digitized";
map[TagTemperature] = "Temperature";
map[TagHumidity] = "Humidity";
map[TagPressure] = "Pressure";
map[TagWaterDepth] = "Water Depth";
map[TagAcceleration] = "Acceleration";
map[TagCameraElevationAngle] = "Camera Elevation Angle";
map[TagWinTitle] = "Windows XP Title";
map[TagWinComment] = "Windows XP Comment";
map[TagWinAuthor] = "Windows XP Author";
Expand Down
12 changes: 12 additions & 0 deletions MetadataExtractor/PublicAPI/net8.0/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#nullable enable
abstract MetadataExtractor.IO.IndexedReader.GetBytes(int index, System.Span<byte> bytes) -> void
abstract MetadataExtractor.IO.SequentialReader.GetBytes(System.Span<byte> bytes) -> void
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagAcceleration = 37892 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagCameraElevationAngle = 37893 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagHumidity = 37889 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagPressure = 37890 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagTemperature = 37888 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagWaterDepth = 37891 -> int
const MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDirectory.TagAEAverage = 6 -> int
const MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDirectory.TagAEMatrix = 2 -> int
const MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDirectory.TagAEStable = 4 -> int
Expand Down Expand Up @@ -75,6 +81,12 @@ MetadataExtractor.Formats.Apple.BplistReader.BplistReader() -> void
MetadataExtractor.Formats.Apple.BplistReader.PropertyListResults
MetadataExtractor.Formats.Apple.BplistReader.PropertyListResults.Get(byte key) -> object!
MetadataExtractor.Formats.Apple.BplistReader.PropertyListResults.GetTopObject() -> System.Collections.Generic.Dictionary<byte, byte>?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetAccelerationDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetCameraElevationAngleDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetHumidityDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetPressureDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetTemperatureDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetWaterDepthDescription() -> string?
MetadataExtractor.Formats.Exif.GpsDirectory.TryGetGeoLocation(out MetadataExtractor.GeoLocation geoLocation) -> bool
MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDescriptor.GetAEStableDescription() -> string?
MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDescriptor.GetAFStableDescription() -> string?
Expand Down
12 changes: 12 additions & 0 deletions MetadataExtractor/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#nullable enable
abstract MetadataExtractor.IO.IndexedReader.GetBytes(int index, System.Span<byte> bytes) -> void
abstract MetadataExtractor.IO.SequentialReader.GetBytes(System.Span<byte> bytes) -> void
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagAcceleration = 37892 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagCameraElevationAngle = 37893 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagHumidity = 37889 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagPressure = 37890 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagTemperature = 37888 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagWaterDepth = 37891 -> int
const MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDirectory.TagAEAverage = 6 -> int
const MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDirectory.TagAEMatrix = 2 -> int
const MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDirectory.TagAEStable = 4 -> int
Expand Down Expand Up @@ -76,6 +82,12 @@ MetadataExtractor.Formats.Apple.BplistReader.BplistReader() -> void
MetadataExtractor.Formats.Apple.BplistReader.PropertyListResults
MetadataExtractor.Formats.Apple.BplistReader.PropertyListResults.Get(byte key) -> object!
MetadataExtractor.Formats.Apple.BplistReader.PropertyListResults.GetTopObject() -> System.Collections.Generic.Dictionary<byte, byte>?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetAccelerationDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetCameraElevationAngleDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetHumidityDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetPressureDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetTemperatureDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetWaterDepthDescription() -> string?
MetadataExtractor.Formats.Exif.GpsDirectory.TryGetGeoLocation(out MetadataExtractor.GeoLocation geoLocation) -> bool
MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDescriptor.GetAEStableDescription() -> string?
MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDescriptor.GetAFStableDescription() -> string?
Expand Down
12 changes: 12 additions & 0 deletions MetadataExtractor/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#nullable enable
abstract MetadataExtractor.IO.IndexedReader.GetBytes(int index, System.Span<byte> bytes) -> void
abstract MetadataExtractor.IO.SequentialReader.GetBytes(System.Span<byte> bytes) -> void
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagAcceleration = 37892 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagCameraElevationAngle = 37893 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagHumidity = 37889 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagPressure = 37890 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagTemperature = 37888 -> int
const MetadataExtractor.Formats.Exif.ExifDirectoryBase.TagWaterDepth = 37891 -> int
const MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDirectory.TagAEAverage = 6 -> int
const MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDirectory.TagAEMatrix = 2 -> int
const MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDirectory.TagAEStable = 4 -> int
Expand Down Expand Up @@ -75,6 +81,12 @@ MetadataExtractor.Formats.Apple.BplistReader.BplistReader() -> void
MetadataExtractor.Formats.Apple.BplistReader.PropertyListResults
MetadataExtractor.Formats.Apple.BplistReader.PropertyListResults.Get(byte key) -> object!
MetadataExtractor.Formats.Apple.BplistReader.PropertyListResults.GetTopObject() -> System.Collections.Generic.Dictionary<byte, byte>?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetAccelerationDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetCameraElevationAngleDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetHumidityDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetPressureDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetTemperatureDescription() -> string?
MetadataExtractor.Formats.Exif.ExifDescriptorBase<T>.GetWaterDepthDescription() -> string?
MetadataExtractor.Formats.Exif.GpsDirectory.TryGetGeoLocation(out MetadataExtractor.GeoLocation geoLocation) -> bool
MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDescriptor.GetAEStableDescription() -> string?
MetadataExtractor.Formats.Exif.Makernotes.AppleMakernoteDescriptor.GetAFStableDescription() -> string?
Expand Down