Copy link to clipboard
Copied
Hi Everyone,
Wondering if anyone can help me. I have some keywords saved in the images IPTC metadata, I'm running a script to which will run different actions on images based on sections of filenames, which works fine. But I want to be able to bring in those keywords from iptc and use those to decide on the actions.
I there any way to bring IPTC data into Javascript as a string? I can do it with normal exif data but I cant for the life of me work this one out.
Thanks in advance!
Richard
1 Correct answer
Some are available by Photoshop scripting. For example:
activeDocument.info.keywords
You can also combine regex with result of:
activeDocument.xmpMetadata.rawData
In that second case doeument must be saved.
What fields exaclty you want to read?
Explore related tutorials & articles
Copy link to clipboard
Copied
Some are available by Photoshop scripting. For example:
activeDocument.info.keywords
You can also combine regex with result of:
activeDocument.xmpMetadata.rawData
In that second case doeument must be saved.
What fields exaclty you want to read?
Copy link to clipboard
Copied
Thanks so much for this. That's exactly what I needed. Worked straight away.
Copy link to clipboard
Copied
I can’t script, however I am guessing that you may need DC:Subject rather than IPTC:Keyword metadata.
This conditional action script does what you require:
Siva's Photoshop Conditional Action: Siva's Photoshop Conditional Action
As does this script:
https://forums.adobe.com/thread/2314586
As an example, if the keyword was “key1” (line 10 below), then run a Photoshop action titled “Molten Lead” in the set “Default Actions” (line 12 below). The action obviously needs to be loaded first, not sure if you can script to ensure that this is the case or not:
#target photoshop;
if(documents.length){
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
var xmp = new XMPMeta(activeDocument.xmpMetadata.rawData);
var shadow = xmp.getProperty(XMPConst.NS_CAMERA_RAW,"ParametricShadowSplit");
var exposureValue = xmp.getProperty(XMPConst.NS_CAMERA_RAW, "Exposure");
var keys = getArrayItems(XMPConst.NS_DC,'subject');
for(var a in keys){
//amend the match for your keywod
if(keys.toString().match(/key1/)){
//things to do if keyword found
app.doAction("Molten Lead","Default Actions.atn")
break;
}
}
};
function getArrayItems(ns, prop){
var arrItem=[];
var items = xmp.countArrayItems(ns, prop);
for(var i = 1;i <= items;i++){
arrItem.push(xmp.getArrayItem(ns, prop, i));
}
return arrItem;
};

