Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Bring IPTC Keyword field data into Javascript as a string

New Here ,
Dec 15, 2017 Dec 15, 2017

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

TOPICS
Actions and scripting
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 15, 2017 Dec 15, 2017

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?

Translate
Adobe
LEGEND ,
Dec 15, 2017 Dec 15, 2017

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 16, 2017 Dec 16, 2017
LATEST

Thanks so much for this. That's exactly what I needed. Worked straight away.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 15, 2017 Dec 15, 2017

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; 

};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines