Copy link to clipboard
Copied
Hi
I´m trying to create a script that stores some xmp informations of photos (like EXIF Data Created...IPTC Core Creator and so on) to variables.
var selected = app.document.selections
var xmp = selected[0].metadata
var creationData = xmp.read (namespace, property)
var author = xmp.read (namespace, property)
In order to do it I need to know the right namespace and property. The Bridge JavaScript reference does not show me a list of what I can use. Do you have any reference to follow?
I´m having no sucess looking over internet. Thank you a lot (again) for the help
Best Regards
Gustavo.
IMO the easiest way is to just select a file in bridge and get info… comm+i and look at the raw data…
Copy link to clipboard
Copied
IMO the easiest way is to just select a file in bridge and get info… comm+i and look at the raw data…
Copy link to clipboard
Copied
Hi Muppet
Yes...its the easy way...but I need to store these names in variables as strings in my scripts because I intent to use these datas to rename files and also folders automatically.
How could I find a list of namespaces and properties to use along the method metadata.read()??
Thank you a lot
Best Regards
Gustavo
Copy link to clipboard
Copied
Hum...interesting Muppet
Now I understand your answer!! haha
I´ll try this and tell you if sucess
Thank you a lot
Best Regards
Copy link to clipboard
Copied
Perfect, Muppet
That´s perfect for raw data (capturing exif)..
How about fields in the IPTC section? How could I reach it??? (like Creator, Keywords, Instructions)....these fields can be edited so I assume I can even write in add to only read.
I´m trying such:
var author = xmp.read("http://www.iptc.org/photometadata/", "Creator")
but it´s not accepting.
Thank you a lot
Gustavo.
Copy link to clipboard
Copied
Oops...found also in Raw data too
var author = xmp.read("http://purl.org/dc/elements/1.1/", "dc:creator")
No questions any longer!
Thank you
Gustavo.
Copy link to clipboard
Copied
You can find the formal spec here http://partners.adobe.com/public/developer/en/xmp/sdk/XMPspecification.pdf
Copy link to clipboard
Copied
Thank you a lot Michael. This document is also very useful. Thank you for sharing.
just one more question. In Bridge JavaScript reference I'm not finding a method for writting values to a specific metadata field. For example I have a name stored to a variable and would like to set it as Creator (IPTC) for the selected image.
The metadata.read allow me to see the values. But how to write in the fields? Like a Document.info property in Photoshop?
Thank you very much
Best regards
Gustavo
Copy link to clipboard
Copied
To do this requires you loading the external XMP library object… You will find this covered in section 10 of the JavaScript Tools Guide ( this is the guide for the non-app specific stuff ). There are also lots of Paul's examples here too…
Copy link to clipboard
Copied
Thank you Muppet
I´m reading that JavaScript reference (at true I´m reading a lot of references..my head is spinning hahaha)...and also saw some Paul´s examples here in the forum
Look at my code (I´m trying to insert my name in the IPTC Core Ceator field). But it does not work. What Am I missing?
var selections = app.document.selections
if (ExternalObject.AdobeXMPScript==undefined){
ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript")
}
var xFile = new XMPFile (selections[0].spec.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE)
var xmp = xFile.getXMP()
xmp.deleteProperty (XMPConst.NS_IPTC_CORE, "Creator")
xmp.setProperty (XMPConst.NS_IPTC_CORE, "Creator", "Gustavo")
if (xFile.canPutXMP(xmp)){
xFile.putXMP(xmp)
xFile.closeFile(XMPConst.CLOSE_UPDATE_SAFETY)
}
Thank you a lot for the help
Best Regards
Gustavo.
Copy link to clipboard
Copied
That field is an Array also Creator should be creator, so it would be ...
var selections = app.document.selections;
if (ExternalObject.AdobeXMPScript==undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");var xFile = new XMPFile (selections[0].spec.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var xmp = xFile.getXMP();
xmp.deleteProperty (XMPConst.NS_IPTC_CORE, "creator");
xmp.appendArrayItem(XMPConst.NS_DC, "creator", "Gustavo", 0, XMPConst.ARRAY_IS_ORDERED);if (xFile.canPutXMP(xmp)){
xFile.putXMP(xmp);
xFile.closeFile(XMPConst.CLOSE_UPDATE_SAFETY);
}
Copy link to clipboard
Copied
Hi Paul
It´s not working yet. Althought it does not get erros...after running the field creator (IPTC) keeps empty.
I made some changes to accomodate all selected thumbnails..made some alternatives but did not have sucess..
Look:
var selected = app.document.selections
var person = prompt("Tell the name of the person", "")
for (var a in selecionados){
var xFile = new XMPFile (selected.spec.fsName, XMPConst.FILE_JPEG, XMPConst.OPEN_FOR_UPDATE);
var xmp = xFile.getXMP();
xmp.deleteProperty (XMPConst.NS_IPTC_CORE, "creator");
xmp.appendArrayItem(XMPConst.NS_IPTC_CORE, "creator", person, 0, XMPConst.ARRAY_IS_ORDERED);
if (xFile.canPutXMP(xmp)){
xFile.putXMP(xmp);
xFile.closeFile(XMPConst.CLOSE_UPDATE_SAFETY);
}
}
Copy link to clipboard
Copied
Does this help...
var selected = app.document.selections
var person = prompt("Tell the name of the person", "")
if (ExternalObject.AdobeXMPScript==undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
for (var a in selected){
var xFile = new XMPFile (selected.spec.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var xmp = xFile.getXMP();
xmp.deleteProperty (XMPConst.NS_DC, "creator");
xmp.appendArrayItem(XMPConst.NS_DC, "creator", person, 0, XMPConst.ARRAY_IS_ORDERED);
if (xFile.canPutXMP(xmp)){
xFile.putXMP(xmp);
xFile.closeFile(XMPConst.CLOSE_UPDATE_SAFETY);
}
}
Copy link to clipboard
Copied
Hey Paul
Now it worked!! Thank you a lot
Comparing the 2 what I see is just a change from NS_IPTC_CORE to NS_DC when deletting and appending the property??? (of couse, there is also the load of the external XMP Script but it I was doing in my original script).
Why did you made this change? Just to better understand the idea!
Thank you a lot and best regards
Gustavo.
Copy link to clipboard
Copied
It was my fault I got it wrong the first time Gustavo
Copy link to clipboard
Copied
Haha, no no, Paul
The NS_IPTC_CORE was written by me in my first approach (the one I posted here). And you corrected it using NS_DC. And I do not understand why IPTC_CORE was wrong hahahah. Would like to understand why NS_DC worked and IPTC_CORE did not work since the creator field is part of the core haha
Best Regards
Gustavo.