Skip to main content
Inspiring
January 12, 2016
Question

How to write xmp data

  • January 12, 2016
  • 1 reply
  • 504 views

How to write XMP data using photo shop script

This topic has been closed for replies.

1 reply

Kasyan Servetsky
Legend
January 12, 2016

I'm not sure what exactly you want to write, but here's an example of writing some data to a custom (for more complexity) namespace:

main();

function main() {

    var prop = "MyProperty";

    var txt = "Blah-blah-blah";

    addMetaData(prop, txt);

}

function addMetaData(prop, txt) {

    if (!ExternalObject.AdobeXMPScript) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript"); 

    var xmp = new XMPMeta(app.activeDocument.xmpMetadata.rawData);

    var theNamespace = "http://ns.xinet.com/ns/xinetschema#";

    var thePrefix = "xwnv:";

    XMPMeta.registerNamespace(theNamespace, thePrefix);

    xmp.setProperty(theNamespace, prop, txt);

    app.activeDocument.xmpMetadata.rawData = xmp.serialize();

}

Before

After