How to write XMP People with a Tag in Universal Apps [UWP]

Using WIC, I can write xmp tag information: Overview of user tags

Now I'm trying to do the same in UWP, but it does not work:

When I try to change only a simple tag, for example "/ xmp / Title", it works.

But when I try to change "PersonDisplayName" or "Rectangle", it does not work.

Code example:

public async void SaveNewPeopleTagged(StorageFile file, string name , string rect) { try { using (IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.ReadWrite), memStream = new InMemoryRandomAccessStream()) { BitmapDecoder decoder = await BitmapDecoder.CreateAsync(fileStream); // Set the encoder destination to the temporary, in-memory stream. BitmapEncoder encoder = await BitmapEncoder.CreateForTranscodingAsync(memStream, decoder); var propertySet = new Windows.Graphics.Imaging.BitmapPropertySet(); BitmapTypedValue btName = new BitmapTypedValue(name, Windows.Foundation.PropertyType.String); //"/xmp/<xmpstruct>MP:RegionInfo/<xmpbag>MPRI:Regions/PersonDisplayName" **is not working** propertySet.Add("/xmp/RegionInfo/Regions/PersonDisplayName", btName); BitmapTypedValue btRect = new BitmapTypedValue(rect, Windows.Foundation.PropertyType.String); //"/xmp/<xmpstruct>MP:RegionInfo/<xmpbag>MPRI:Regions/Rectangle" **is not working** propertySet.Add("/xmp/RegionInfo/Regions/Rectangle", btRect); await encoder.BitmapProperties.SetPropertiesAsync(propertySet); //**Give a exception... "Value does not fall within the expected range."** //If I use only : propertySet.Add("/xmp/Title", ...); it is working await encoder.FlushAsync(); await memStream.FlushAsync(); memStream.Seek(0); fileStream.Seek(0); fileStream.Size = 0; await RandomAccessStream.CopyAsync(memStream, fileStream); } } catch (Exception err) { Debug.WriteLine(err.Message); } } 

Does anyone have any ideas or suggestions?

thanks

+5
source share
1 answer

This works for me:

 int n = 0; // nth entry propertySet.Add("/xmp/<xmpstruct>MP:RegionInfo/<xmpbag>MPRI:Regions/<xmpstruct>{ulong=" + n + "}/MPReg:Rectangle", new BitmapTypedValue(rect, PropertyType.String)); propertySet.Add("/xmp/<xmpstruct>MP:RegionInfo/<xmpbag>MPRI:Regions/<xmpstruct>{ulong=" + n + "}/MPReg:PersonDisplayName", new BitmapTypedValue(name, PropertyType.String)); 
+3
source

Source: https://habr.com/ru/post/1243975/


All Articles