Here's a quick question: how to correctly add a custom namespace to XMP using BitmapMetadata
?
Let's say I want the namespace to look like this: xmlns:MyNamespace="http://test"
There's no clear way how to add the namespace in the BitmapMetadata
, so I tried this:
//I retrieve the image frame (Frame[0]), then:
var metadata = (BitmapMetadata) frame.Metadata.Clone();
//Covering all bases
metadata.SetQuery("/app1/ifd/PaddingSchema:Padding", 4096);
metadata.SetQuery("/app1/ifd/exif/PaddingSchema:Padding", 4096);
metadata.SetQuery("/xmp/PaddingSchema:Padding", 4096);
And now the main query, I tried going the 'obvious way':
metadata.SetQuery("/xmp/MyNamespace:MyTag", "AwesomeTagValue");
And sure enough, if I save the image, open it and run
var value = (string) metadata.GetQuery("/xmp/MyNamespace:MyTag");
it returns the correct value - AwesomeTagValue.
Here's the problem though, the tags are written to the file with malformed namespace. I peeked into the file and here's the stripped XML/RDF view:
<rdf:Description rdf:about="" xmlns:prefix0="MyNamespace"> ... </rdf:Description>
so all the tags are prefixed with prefix0
and I'd like it to be
<rdf:Description rdf:about="" xmlns:MyNamespace="http://test"> ... </rdf:Description>
Any ideas how to do that or if it's even possible with BitmapMetadata
?