PureBasic
PureBasic
Update a String Property in XMP
See more XMP Examples
Demonstrates how to open a JPG or TIF image file, access the XMP metadata, and update the value of a string property. (If the string property does not already exist, it is created.)Chilkat PureBasic Downloads
IncludeFile "CkXml.pb"
IncludeFile "CkXmp.pb"
Procedure ChilkatExample()
success.i = 0
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
xmp.i = CkXmp::ckCreate()
If xmp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Load a JPG or TIF image file.
success = CkXmp::ckLoadAppFile(xmp,"qa_data/xmp/AJ_123642_1511.tif")
If success <> 1
Debug CkXmp::ckLastErrorText(xmp)
CkXmp::ckDispose(xmp)
ProcedureReturn
EndIf
Debug "Num embedded XMP docs: " + Str(CkXmp::ckNumEmbedded(xmp))
; This example assumes that XMP metadata is already present in the image file.
If CkXmp::ckNumEmbedded(xmp) = 0
Debug "No XMP metadata already exists.."
CkXmp::ckDispose(xmp)
ProcedureReturn
EndIf
; Get the XMP metadata.
xml.i
xml = CkXmp::ckGetEmbedded(xmp,0)
; Show the XML:
Debug CkXml::ckGetXml(xml)
; Update (overwrite) a string property.
CkXmp::ckAddSimpleStr(xmp,xml,"NumberofTimes","123")
success = CkXmp::ckSaveAppFile(xmp,"qa_output/updated.tif")
If success <> 1
Debug CkXmp::ckLastErrorText(xmp)
CkXmp::ckDispose(xmp)
ProcedureReturn
EndIf
Debug "Success."
CkXmp::ckDispose(xmp)
ProcedureReturn
EndProcedure