public Metadata GetMetadata(object target) { if (target == null || !(target is string)) { return(null); } string filename = target.ToString(); ImageMetadata metadata = new ImageMetadata(); using (Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) { PropertyItem[] propertyItems; try { using (System.Drawing.Image image = System.Drawing.Image.FromStream(stream, true, false)) { try { propertyItems = image.PropertyItems; } catch (NotImplementedException ex) { // TODO: Log exception; propertyItems = new PropertyItem[0]; } } } catch (ArgumentException ex) { // TODO: Log exception; propertyItems = new PropertyItem[0]; } foreach (PropertyItem propertyItem in propertyItems) { System.Diagnostics.Debug.WriteLine(propertyItem.Id); if (Enum.IsDefined(typeof(ImagePropertyTags), propertyItem.Id)) { metadata.AddPropertyItem(propertyItem); } } } BitmapFrame frame = BitmapFrame.Create(new Uri(filename), BitmapCreateOptions.IgnoreImageCache, BitmapCacheOption.OnLoad); BitmapMetadata bitmapMetadata = frame.Metadata as BitmapMetadata; if (bitmapMetadata != null) { metadata.AddBitmapMetadata(bitmapMetadata); } return(metadata); }