Skip to content

Commit

Permalink
Add sample showing consumption of XMP metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
drewnoakes committed May 22, 2023
1 parent 8119fb9 commit 4d9d59a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions MetadataExtractor.Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using MetadataExtractor.Formats.Exif;
using MetadataExtractor.Formats.Iptc;
using MetadataExtractor.Formats.Jpeg;
using MetadataExtractor.Formats.Xmp;

#pragma warning disable 8321

Expand Down Expand Up @@ -114,6 +115,15 @@ static void Print(IEnumerable<Directory> directories, string method)
foreach (var tag in directory.Tags)
Console.WriteLine(tag);

// XMP values are handled slightly differently
if (directory is XmpDirectory { XmpMeta: { } xmpMeta })
{
foreach (var property in xmpMeta.Properties)
{
Console.WriteLine($"{property.Namespace} :: {property.Path} = {property.Value}");
}
}

// Each directory may also contain error messages
foreach (var error in directory.Errors)
Console.Error.WriteLine("ERROR: " + error);
Expand Down

0 comments on commit 4d9d59a

Please sign in to comment.