public void UpdateXMPData() { try { //ExStart:UpdateXMP // path to the modified file string filePath = "Images/Jpeg/sample.jpg"; // get xmp wrapper XmpPacketWrapper xmpWrapper = MetadataUtility.ExtractXmpPackage(filePath); // if wrapper is null if (xmpWrapper == null) { // create it xmpWrapper = new XmpPacketWrapper(); } // create package XmpPackage addingSchema = new XmpPackage("rs", "http://www.metadataworkinggroup.com/schemas/regions/"); // set date property addingSchema.AddValue("rs:createdDate", DateTime.UtcNow); // set string property addingSchema.AddValue("rs:File", "File name"); //initialze unordered xmp array XmpArray managersArray = new XmpArray(XmpArrayType.UNORDERED); managersArray.AddItem("Joe Doe"); managersArray.AddItem("Adam White"); // set array property addingSchema.SetArray("rs:managers", managersArray); // initialize xmp language alternative LangAlt availableDays = new LangAlt(); // add first value for 'en-us' language availableDays.AddLanguage("en-us", "Tue"); // add second value for 'en-us' languge availableDays.AddLanguage("en-us", "Fri"); // set LangAlt property addingSchema.SetLangAlt("rs:days", availableDays); // update xmp wrapper with new schema xmpWrapper.AddPackage(addingSchema); // create XmpMetadata with updated wrapper XmpMetadata xmpMetadata = new XmpMetadata(); xmpMetadata.XmpPacket = xmpWrapper; // update XMP MetadataUtility.UpdateMetadata(filePath, xmpMetadata); //ExEnd:UpdateXMP } catch (Exception exp) { } }
public void CreateDerivedXMPTypes() { //ExStart:CreateXMPGuid // init new C# struct Guid Guid guid = Guid.NewGuid(); // create xmp guid using C# struct XmpGuid xmpGuid = new XmpGuid(guid); // create xmp guid using it's string representation XmpGuid xmpGuid2 = new XmpGuid(guid.ToString()); //ExEnd:CreateXMPGuid //ExStart:CreateRational int numerator = 1; int denominator = 10; // create xmp rational Rational rational = new Rational(numerator, denominator); // float value should be 0.1 float value = rational.FloatValue; //ExEnd:CreateRational //ExStart:CreateLanguageAlternative // init LangAlt with default value LangAlt langAlt = new LangAlt("XMP - Extensible Metadata Platform"); // add value for en-us language langAlt.AddLanguage("en-us", "XMP - Extensible Metadata Platform"); // add value for French language langAlt.AddLanguage("fr", "XMP - Une Platforme Extensible pour les Métadonnées"); //ExEnd:CreateLanguageAlternative }