Reading XMP MetaData Keywords with WPF

WPF has an interesting way to read metadata associated with a photo.  All metadata can be extracted using the BitmapMetaData object.  The BitmapMetaData object supports the various metadata schemas including: Exif, tEXt, IFD, IPTC and XMP.

Here's a simply way to read an existing image's metada with C#:

BitmapMetadata metadata = (BitmapMetadata)myImage.Source.Metadata;

MessageBox.Show(metadata.Title);

Looking at the BitMapMetaData, you can find out all sorts of information such as camera model, date taken, caption, etc.  In particular, I was interested in reading the Tags added by Windows Photo Gallery in Vista.  The Microsoft Photography Blog article states that "All metadata written to photos by Windows Vista will be written to XMP (always directly to the file itself, never to a ‘sidecar’ file)."  Furthermore, I found that the tags are stored in the keywords collection in the metadata. Simple enough. I expanded my sample yesterday to display the tags associated with an image when it's selected. 

I haven't figured a way to programmatically add new tags to the images yet. I have some code in the demo to add new tags using the InPlaceBitmapMetadataWriter object that doesn't work. Let me know if I'm missing something.

An aside, the demo now also supports multiple files drag and drop.  I also cleaned up the styling a bit.

DragDropMedia2

Source: http://blogs.vertigosoftware.com/files/alan/dragdropmedia.zip

Compiled and Programmed with .NET 3.0 Framework.

posted on Friday, December 01, 2006 3:23 PM by AlanL

Comments

# re: Reading XMP MetaData Keywords with WPF

Wednesday, December 13, 2006 2:00 AM by thomas
project open failed

# re: Reading XMP MetaData Keywords with WPF

Wednesday, December 27, 2006 10:43 AM by Aaron
FYI - this project appears to be the older version, without the tag displaying support.

# re: Reading XMP MetaData Keywords with WPF

Sunday, January 21, 2007 12:43 PM by thomas
ok, thank you

# re: Reading XMP MetaData Keywords with WPF

Thursday, April 26, 2007 3:17 PM by John
the project .zip still appears to be the older version without the tag displaying support.