Xbase++
Xbase++
XMP Array Property - Bag, Seq, or Alt
See more XMP Examples
How to insert or update an XMP array property (bag, seq, or alt).Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oXmp
LOCAL oXml
LOCAL oSa
nSuccess := 0
// This requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oXmp := CreateObject("Chilkat.Xmp")
// Load a JPG or TIF image file.
// Sample JPG's with XMP metadata may be found at:
// http://www.chilkatsoft.com/testData/xmp/sample1.jpg
// http://www.chilkatsoft.com/testData/xmp/sample2.jpg
// http://www.chilkatsoft.com/testData/xmp/sample3.jpg
nSuccess := oXmp:LoadAppFile("sample1.jpg")
IF (nSuccess != 1)
? oXmp:LastErrorText
oXmp:destroy()
RETURN
ENDIF
? "Num embedded XMP docs: " + Str(oXmp:NumEmbedded)
// Assuming there is at least one, get the 1st.
// (There is typically never more than one, but theoretically it's possible.)
oXml := oXmp:GetEmbedded(0)
IF (oXmp:LastMethodSuccess == 1)
// Create an object to hold one or more string values.
oSa := CreateObject("Chilkat.StringArray")
nSuccess := oSa:Append("value_1")
nSuccess := oSa:Append("value_2")
// ...
nSuccess := oXmp:AddArray(oXml, "bag", "Iptc4xmpCore:Chilkat", oSa)
IF (nSuccess != 1)
? oXmp:LastErrorText
ELSE
// Save the JPG.
nSuccess := oXmp:SaveAppFile("modified.jpg")
IF (nSuccess != 1)
? oXmp:LastErrorText
ENDIF
ENDIF
oXml:destroy()
ELSE
? oXmp:LastErrorText
ENDIF
oXmp:destroy()
oSa:destroy()