18 December 2006

Vista Image XMP Tags

Microsoft Windows Vista lets you set various meta-data properties for image files, ie JPEG and TIFF files. A new feature is to add one or more Tags to a picture.

Previously, meta-data information was added to image files using EXIF (Exchangeable Image File Format). However Vista adds image meta-data using XMP (Extensible Metadata Platform) - this is XML-formatted information embedded in the image file. Click here to get the XMP spec. Where possible the meta-data is also stored in the corresponding EXIF data.

Using the ASP.NET System.Drawing.Image class, it did not seem to be possible to extract the XMP data in a JPEG file. The XMP is stored in an APP1 section. To find it, I therefore did a somewhat nasty binary scan for these 29 characters http://ns.adobe.com/xap/1.0/ and then checked for the APP1 marker 0xFFE1 two words before. The first word beforehand then contains APP1 size. The XMP Packet byte[] can then be extracted and decoded from UTF-8.

For TIFF files, System.Drawing.Image returns the XMP byte[] data as property id 700.

For both file types, the XMP Packet can then be loaded using System.Xml.XmlDocument. The actual XML lets you extract data from these fields (the Vista usage is in brackets):

  • dc:subject (Tags)

  • dc:title (Title)

  • dc:creator (Author)

  • dc:description (Subject)

  • dc:rights (Copyright)

  • tiff:artist (Author)

  • exif:UserComment (Comments)

  • xmp:Rating (Star rating number)

  • MicrosoftPhoto:LastKeywordXMP (seems to the same as dc:subject)

  • MicrosoftPhoto:Rating (not sure what this is)


The actual field values are in plain text, rdf:Bag, rdf:Alt or rdf:Seq lists.

I did this work to add the meta-data information to that found by my ASP.NET search engine FindinSite-MS.

1 comment:

Daniel said...

Hello Chris,

I am currently trying to develop an app in VB.NET that will tag a specified image. Therefore I was wondering if you knew how I could possibly write to XMP?

Thanks very much!
Daniel Sandberg