Skip to main content
Participant
September 13, 2013
Question

Enter Dublin Core XMP in Bridge metadata window

  • September 13, 2013
  • 1 reply
  • 4005 views

Someone in the general discussion area suggested I cross-post this question here:

I'm trying to find the best way to add some Dublin Core into TIFF files. Basically I'd like to add data to the dc:identifier and dc:relation fields while I'm adding other data in Bridge.  Is there a way to create a tab for Dublin Core in the metadata window? 

Currently we're using Bridge and IPTC core was working okay, but now we need to add some metadata that would fit better in Dublin Core.  I know it has a namespace in XMP, but can't figure out a way to use Bridge or Photoshop to enter it.

I have tried to adapt a script created by Paul Riggott in this thread, but have been unable to make it work.

I also tried the "add identifier" script in this thread, but I'm not seeing how it works... probably because it was written for the Mac and I'm working in Windows. Any suggestions?

Thanks.

This topic has been closed for replies.

1 reply

Pedro Cortez Marques
Legend
September 26, 2013

Hi Regina

I add also to built this on the past months. Here is the result.

You cant try it first on STDK targeting bridge first but then oyu can put this code inside an '*.onClick' function action button on a snp subwindow on bridge.

This works well to create your own namespace and prefix or add properties on other existing namespaces. In this case I have used Dublin Core namespace

Hope it helps.

Pedro Cortez Marques

__________________

// This only works on bridge!!

//

loadXMPLib();

// Here put the namepace and the prefix (you can create also your own new namespace and prefix)

// In this case, it uses the Dublin Core Properties

var psNamespace = "http://purl.org/dc/elements/1.1/";

var psPrefix = "dc:";

XMPMeta.registerNamespace(psNamespace, psPrefix);

// Here you have to choose 1, 2, or multiple thumbnails. In this case it chooses all tiff files found on content pane.

var sels = app.document.visibleThumbnails;

for (var b in sels) {

    // Here I choose tif files, but you can set (cr2|raw|dng|nef/jpg) for raw and jpg files leave it empty for any file except folders

    if (sels.spec instanceof File && sels.name.match(/\.(cr2|raw|dng|nef)$/i)) {

        var xmp = new XMPMeta(sels.synchronousMetadata.serialize());       

        // I can create new Properties in Dublin Core and add values to them

        xmp.setProperty(psNamespace, "MyProp01", 'some text here');

        xmp.setProperty(psNamespace, "MyProp02", 'false');

        xmp.setProperty(psNamespace, "MyProp03", '32895665');

        xmp.setProperty(psNamespace, "MyProp04", 'label2');

        // Or, you can use the DublinCore native properties.

        // In this case, I want to ADD some text to 'Descrition' existing text ('Description is a 'langAlt' property)

        // First, I read any Descrition value and add it to a var

        var Description =  xmp.getArrayItem(XMPConst.NS_DC, "description",1);

        // Then I add may new tex to that existing value:

        // (I wanted to put the return '\r' (or new line '\n') to add new paragraphs in the middle of text: "\rline2\rline3")

        xmp.setLocalizedText(XMPConst.NS_DC, "description", null, "x-default", Description + "\rlinha2\nlinha3");

        // If you want to delete any existing value and create new value directly use this instead:

        // xmp.setLocalizedText(XMPConst.NS_DC, "description", null, "x-default", "Nota");

        //

        var updatedPacket = xmp.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT);

        sels.metadata = new Metadata(updatedPacket);

    }

}

//

unloadXMPLib();

// Functions needed:

///////////////////////////////

function loadXMPLib() {

    if( xmpLib == undefined ) {

          if( Folder.fs == "Windows" ) {

              var pathToLib = Folder.startup.fsName + "/AdobeXMPScript.dll";

          } else {

              var pathToLib = Folder.startup.fsName + "/AdobeXMPScript.framework";

          }

          var libfile = new File( pathToLib );

          var xmpLib = new ExternalObject("lib:" + pathToLib );

    }

}

///////////////////////////////

function unloadXMPLib() {

    if ( ExternalObject.AdobeXMPScript ) {

        try {

            ExternalObject.AdobeXMPScript.unload();

            ExternalObject.AdobeXMPScript = undefined;

        }catch (e) { }

    }

}

a_reginaAuthor
Participant
October 8, 2013

Thank you very much for responding, Pedro! I haven't created an onclick action button before. Is that something I do in the ExtendScript Toolkit? I'm still trying to figure this out since I don't know javascript. Any guidance here is appreciated.

Thanks again,

a.regina

Pedro Cortez Marques
Legend
October 8, 2013

If you use Bridge CS6, you must first download the ready made scripts 'Bridge CS6 SDK' here:

http://www.adobe.com/devnet/bridge/eula_cs6.html

(choose windows or mac version at the end of page)

You will find several useful scripts on this folder:

/sdksamples/javascript/

The one you need to add a new panel is:

SnpCreateTabbedPaletteScriptUI.jsx


Before you change ths script, test it by putting this script in the startupt bridge scripts folder (Bridge > Preferences > Startup Scripts > Reveal My Startup Scripts button)

Then you can open it and you only need to change the part where it creates the buttons (you can create other buttons too).

Here is the native code:

// Add the UI components to the ScriptUI panel

tbPanel.txtFieldLbl = tbPanel.add('statictext', [15,15,105,35], 'Times Clicked:');

tbPanel.txtField = tbPanel.add('edittext', [115,15,215,35], '0');

tbPanel.addBtn = tbPanel.add('button', [15,65,105,85], 'Add'); // change the name of the button here

tbPanel.subBtn = tbPanel.add('button', [120, 65, 210, 85], "Sub");

// Define event listeners that implement behavior for the UI components

tbPanel.addBtn.onClick = function()

{

          var txt = tbPanel.txtField;

          txt.text = parseInt(txt.text) + 1;

// you can put my XMP code here

}

tbPanel.subBtn.onClick = function()

{

          var txt = tbPanel.txtField;

          txt.text = parseInt(txt.text) - 1;

}