Reading People Tags inserted into Windows Live Photo Gallery

Photo Gallery gives you the opportunity to mark the face of a person and apply a tag to it. I understand that it inserts tags directly into the file, and does not save it in the database or the accompanying metafile anywhere.

So, if true, what data does it insert and how is it formatted?

+4
source share
2 answers

Here is the code I wanted. This is in C #.

public void ReadWLPGRegions(string sourceFile) { string microsoftRegions = @"/xmp/RegionInfo/Regions"; string microsoftPersonDisplayName = @"/PersonDisplayName"; string microsoftRectangle = @"/Rectangle"; BitmapCreateOptions createOptions = BitmapCreateOptions.PreservePixelFormat | BitmapCreateOptions.IgnoreColorProfile; using (Stream sourceStream = File.Open(sourceFile, FileMode.Open, FileAccess.Read)) { BitmapDecoder sourceDecoder = BitmapDecoder.Create(sourceStream, createOptions, BitmapCacheOption.None); // Check source has valid frames if (sourceDecoder.Frames[0] != null && sourceDecoder.Frames[0].Metadata != null) { BitmapMetadata sourceMetadata = sourceDecoder.Frames[0].Metadata as BitmapMetadata; // Check there is a RegionInfo if (sourceMetadata.ContainsQuery(microsoftRegions)) { BitmapMetadata regionsMetadata = sourceMetadata.GetQuery(microsoftRegions) as BitmapMetadata; // Loop through each Region foreach (string regionQuery in regionsMetadata) { string regionFullQuery = microsoftRegions + regionQuery; // Query for all the data for this region BitmapMetadata regionMetadata = sourceMetadata.GetQuery(regionFullQuery) as BitmapMetadata; if (regionMetadata != null) { if (regionMetadata.ContainsQuery(microsoftPersonDisplayName) && regionMetadata.ContainsQuery(microsoftRectangle)) { Console.Writeline( regionMetadata.GetQuery(microsoftRectangle).ToString())); Console.WriteLine(regionMetadata.GetQuery(microsoftPersonDisplayName).ToString())); } } } } } } } 
+4
source

When possible, Windows Live Photo Gallery uses XMP to write metadata to image files. See Windows Vista Metadata and Photo Gallery for more information.

+1
source

All Articles