static void CopyFile() { using (var bmp = WicBitmapSource.Load(@"SamsungSGH-I777.jpg")) { // get metadata source (reader) var reader = bmp.GetMetadataReader(); //var th = bmp.GetThumbnail(); // gt policies (well known Windows metadata) var policies = new WicMetadataPolicies(reader); // dump metadata to console reader.Visit((r, kv) => { var value = kv.Value; var type = value != null ? value.GetType().Name : null; if (value is byte[] bytes) { value = Conversions.ToHexa(bytes, 64) + " (" + bytes.Length + ")"; } Console.WriteLine(WicMetadataKey.CombineKeys(r.Location, kv.Key.Key) + " [" + type + "/" + kv.Type + "]= " + value); }); // save with metadata bmp.Save("copy.jpg", metadata: reader); } }
static void Dump(WicMetadataQueryReader reader) { // gt policies (well known Windows metadata) var policies = new WicMetadataPolicies(reader); // dump metadata to console reader.Visit((r, kv) => { var value = kv.Value; var type = value != null ? value.GetType().Name : null; if (value is byte[] bytes) { value = Conversions.ToHexa(bytes, 64) + " (" + bytes.Length + ")"; } Console.WriteLine(WicMetadataKey.CombineKeys(r.Location, kv.Key.Key) + " [" + type + "/" + kv.Type + "]= " + value); }); }