Ask a questionAsk a question
 

Proposed AnswerAdding custom XMP metadata

  • Friday, June 05, 2009 2:27 PMNathan_V Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I am trying to add custom XMP metadata to JPG files via BitmapMetadata.SetQuery.   My code works fine for modifying predefined metadata but I am stuck on trying to use a custom schema in a namespace.  I have read the relevent portions of the XMP spec but don't see any exposed methods to define a custom namespace in the metadata.  I tried this WAG approach:

              BitmapMetadata metadata = frame.Metadata.Clone() as BitmapMetadata;
              // I figure I only need to pad /XMP but for now I pad EVERYTHING
              metadata.SetQuery("/app1/ifd/PaddingSchema:Padding", paddingAmount);
              metadata.SetQuery("/app1/ifd/exif/PaddingSchema:Padding", paddingAmount);
              metadata.SetQuery("/xmp/PaddingSchema:Padding", paddingAmount);
              // Now add data using my totally made up namespace.
              metadata.SetQuery("/xmp/NX:NXData", "Hello World");

    This "works" in that SetQuery succeeds but when I try to save the file I get an overflow exception.  If I change the query to a known good metadata field it works fine.    I hope I am missing something obvious here but nothing about this project has been obvious so far...

    Thanks,
    Nathan

All Replies