Skip to content

Commit

Permalink
Merge pull request #307 from drewnoakes/geotiff
Browse files Browse the repository at this point in the history
Add GeoTIFF support
  • Loading branch information
drewnoakes authored Aug 2, 2021
2 parents 91afbbb + 87be85e commit 01c987f
Show file tree
Hide file tree
Showing 21 changed files with 3,087 additions and 157 deletions.
2 changes: 2 additions & 0 deletions MetadataExtractor.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LV/@EntryIndexedValue">LV</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MM/@EntryIndexedValue">MM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ND/@EntryIndexedValue">ND</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NW/@EntryIndexedValue">NW</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OS/@EntryIndexedValue">OS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RG/@EntryIndexedValue">RG</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UI/@EntryIndexedValue">UI</s:String>
Expand Down Expand Up @@ -71,6 +72,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Heif/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=HEVC/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ICCP/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ifds/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=IFD_0027s/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ilist/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Illuminator/@EntryIndexedValue">True</s:Boolean>
Expand Down
13 changes: 13 additions & 0 deletions MetadataExtractor/Directory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ public virtual void Set(int tagType, object value)

#endregion

public void RemoveTag(int tagId)
{
if (_tagMap.Remove(tagId))
{
var index = _definedTagList.FindIndex(tag => tag.Type == tagId);

if (index != -1)
{
_definedTagList.RemoveAt(index);
}
}
}

/// <summary>Returns the name of a specified tag as a String.</summary>
/// <param name="tagType">the tag type identifier</param>
/// <returns>the tag's name as a String</returns>
Expand Down
40 changes: 40 additions & 0 deletions MetadataExtractor/Formats/Exif/ExifDescriptorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ protected ExifDescriptorBase(T directory)
TagCompression => GetCompressionDescription(),
TagJpegProc => GetJpegProcDescription(),
TagLensSpecification => GetLensSpecificationDescription(),
TagExtraSamples => GetExtraSamplesDescription(),
TagSampleFormat => GetSampleFormatDescription(),
_ => base.GetDescription(tagType),
};

Expand Down Expand Up @@ -954,5 +956,43 @@ internal static string GetWhiteBalanceDescription(int value)
_ => "Unknown (" + value + ")",
};
}

public string? GetExtraSamplesDescription()
{
return GetIndexedDescription(
TagExtraSamples,
"Unspecified",
"Associated alpha",
"Unassociated alpha");
}

public string? GetSampleFormatDescription()
{
var values = Directory.GetInt32Array(TagSampleFormat);

if (values is null)
return null;

var sb = new StringBuilder();

foreach (var value in values)
{
if (sb.Length != 0)
sb.Append(", ");

sb.Append(value switch
{
1 => "Unsigned",
2 => "Signed",
3 => "Float",
4 => "Undefined",
5 => "Complex int",
6 => "Complex float",
_ => $"Unknown ({value})"
});
}

return sb.ToString();
}
}
}
22 changes: 22 additions & 0 deletions MetadataExtractor/Formats/Exif/ExifDirectoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ public abstract class ExifDirectoryBase : Directory
/// <remarks>Seems to be used exclusively by raw formats, referencing one or two IFDs.</remarks>
public const int TagSubIfdOffset = 0x014a;

public const int TagExtraSamples = 0x0152;
public const int TagSampleFormat = 0x0153;

public const int TagTransferRange = 0x0156;

public const int TagJpegTables = 0x015B;
Expand Down Expand Up @@ -206,12 +209,22 @@ public abstract class ExifDirectoryBase : Directory
/// <summary>The actual F-number(F-stop) of lens when the image was taken.</summary>
public const int TagFNumber = 0x829D;

public const int TagPixelScale = 0x830E;

public const int TagIptcNaa = 0x83BB;

public const int TagModelTiePoint = 0x8482;

public const int TagPhotoshopSettings = 0x8649;

public const int TagInterColorProfile = 0x8773;

public const int TagGeoTiffGeoKeys = 0x87af;

public const int TagGeoTiffGeoDoubleParams = 0x87b0;

public const int TagGeoTiffGeoAsciiParams = 0x87b1;

/// <summary>Exposure program that the camera used when image was taken.</summary>
/// <remarks>
/// '1' means
Expand Down Expand Up @@ -697,6 +710,9 @@ public abstract class ExifDirectoryBase : Directory
/// <summary>String.</summary>
public const int TagLensSerialNumber = 0xA435;

public const int TagGdalMetadata = 0xA480;
public const int TagGdalNoData = 0xA481;

/// <summary>Rational64u.</summary>
public const int TagGamma = 0xA500;

Expand Down Expand Up @@ -758,6 +774,8 @@ protected static void AddExifTagNames(Dictionary<int, string> map)
map[TagTileOffsets] = "Tile Offsets";
map[TagTileByteCounts] = "Tile Byte Counts";
map[TagSubIfdOffset] = "Sub IFD Pointer(s)";
map[TagExtraSamples] = "Extra Samples";
map[TagSampleFormat] = "Sample Format";
map[TagTransferRange] = "Transfer Range";
map[TagJpegTables] = "JPEG Tables";
map[TagJpegProc] = "JPEG Proc";
Expand Down Expand Up @@ -785,7 +803,9 @@ protected static void AddExifTagNames(Dictionary<int, string> map)
map[TagCopyright] = "Copyright";
map[TagExposureTime] = "Exposure Time";
map[TagFNumber] = "F-Number";
map[TagPixelScale] = "Pixel Scale";
map[TagIptcNaa] = "IPTC/NAA";
map[TagModelTiePoint] = "Model Tie Point";
map[TagPhotoshopSettings] = "Photoshop Settings";
map[TagInterColorProfile] = "Inter Color Profile";
map[TagExposureProgram] = "Exposure Program";
Expand Down Expand Up @@ -874,6 +894,8 @@ protected static void AddExifTagNames(Dictionary<int, string> map)
map[TagLensMake] = "Lens Make";
map[TagLensModel] = "Lens Model";
map[TagLensSerialNumber] = "Lens Serial Number";
map[TagGdalMetadata] = "GDAL Metadata";
map[TagGdalNoData] = "GDAL No Data";
map[TagGamma] = "Gamma";
map[TagPrintImageMatchingInfo] = "Print Image Matching (PIM) Info";
map[TagPanasonicTitle] = "Panasonic Title";
Expand Down
Loading

0 comments on commit 01c987f

Please sign in to comment.