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

Enter Dublin Core XMP in Bridge metadata window

New Here ,
Sep 13, 2013 Sep 13, 2013

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.

TOPICS
Scripting
3.9K
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
Enthusiast ,
Sep 26, 2013 Sep 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) { }

    }

}

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 ,
Oct 07, 2013 Oct 07, 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

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
Enthusiast ,
Oct 08, 2013 Oct 08, 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;

}

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 ,
Oct 15, 2013 Oct 15, 2013

Hello again,

I'm using Bridge CS4, but I was able to find that script and place it in Bridge's scripts folder.

When Bridge opens, I get an error window that says,

"Attempt to set $.level to 1 without permission!"

After I close the error window, I see the new panel.

When I run the script from the In the Extend Script Toolkit window, line 73 is highlighted:

var scriptPalette = new TabbedPalette( doc, "SnpCreateTabbedPaletteScriptUI", "SnpSUIPalette", "script" );

It seems to stall there.

I went ahead and replaced the crossed out lines above with your XMP script, but still see the same line highlighted in the Extend Script Toolkit.

Do you have any ideas why that might be happening?

Thanks again for your help.

a.regina

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 ,
Oct 15, 2013 Oct 15, 2013

Sorry, I should probably include the code as I amended it:

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

// ADOBE SYSTEMS INCORPORATED

// Copyright 2008 Adobe Systems Incorporated

// All Rights Reserved

//

// NOTICE:  Adobe permits you to use, modify, and distribute this file in accordance with the

// terms of the Adobe license agreement accompanying it.  If you have received this file from a

// source other than Adobe, then your use, modification, or distribution of it requires the prior

// written permission of Adobe.

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

/**

@fileoverview Shows how to create a TabbedPalette in Bridge with ScriptUI components.

@class Shows how to create a TabbedPalette in Bridge with ScriptUI components.

<h4>Usage</h4>

<ol>

<li>    Run the snippet in the ExtendScript Toolkit (see Readme.txt), with Bridge CS4 as the target.

<li>You should find that a tabbed palette has been added to the Bridge browser window.

</ol>

<h4>Description</h4>

<p>Adds a script-defined tabbed palette to the Bridge browser window. 

<p>The palette is of the "script" type, and contains ScriptUI components,

text fields and buttons. The buttons have event handlers that

change the values in the text fields.

<p>The new palette appears in the default upper-left position in the browser. It can be

  dragged to other positions. <br />

 

@see SnpCreateWebTabbedPalette

@constructor Constructor.

*/

function SnpCreateTabbedPaletteScriptUI()

{

    /**

     The context in which this snippet can run.

     @type String

    */

    this.requiredContext = "\tExecute against Bridge main engine.\nBridge must not be running";

    $.level = 1; // Debugging level

    this.paletteRefs = null;

}

/**

Functional part of this snippet. 

Creates the TabbedPalette object, defining the content with

ScriptUI components, and adds the palette to all open Bridge browser windows.

    @return True if the snippet ran as expected, false otherwise. 

    @type Boolean

*/

SnpCreateTabbedPaletteScriptUI.prototype.run = function()

{

   

    var retval = true;

    if(!this.canRun())

    {

        retval = false;   

        return retval;

    }

    this.paletteRefs = new Array();

    var wrapper = this;

    // Create and add the TabbedPalette object and its contents.

    function addScriptPalette(doc)

    {

        // Create the TabbedPalette object, of type "script"

        var scriptPalette = new TabbedPalette( doc, "SnpCreateTabbedPaletteScriptUI", "SnpSUIPalette", "script" );

        wrapper.paletteRefs.push(scriptPalette);   

        // Create a ScriptUI panel to be displayed as the tab contents.

        var tbPanel = scriptPalette.content.add('panel', [25,15,255,130], 'The Panel');

        // 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');

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

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

        tbPanel.addBtn.onClick = function()

        {

// 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) { }

    }

}

        }

       

        tbPanel.subBtn.onClick = function()

        {

            var txt = tbPanel.txtField;

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

        }

    }

    // Add the palette to all open Bridge browser windows

    for(var i = 0;i < app.documents.length;i++)

    {

        addScriptPalette(app.documents);

    }

    return retval;

}

/**

  Determines whether snippet can be run given current context.  The snippet

  fails if these preconditions are not met:

  <ul>

  <li> Must be running in Bridge

  </ul>

  @return True is this snippet can run, false otherwise

  @type boolean

*/

SnpCreateTabbedPaletteScriptUI.prototype.canRun = function()

{   

   

    // Must run in Bridge

    if(BridgeTalk.appName == "bridge")

    {

        return true;       

    }

   

    // Fail if these preconditions are not met. 

    // Bridge must be running,

    $.writeln("ERROR:: Cannot run SnpCreateTabbedPaletteScriptUI");

    $.writeln(this.requiredContext);

    return false;

   

}

/**

"main program": construct an anonymous instance and run it

  as long as we are not unit-testing this snippet.

*/

if(typeof(SnpCreateTabbedPaletteScriptUI_unitTest) == "undefined") {

    new SnpCreateTabbedPaletteScriptUI().run();

}

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
Enthusiast ,
Oct 16, 2013 Oct 16, 2013
LATEST

For BridgeCS4 you must test with the SDK for CS4:

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

The same if regarding photoshop:

http://www.adobe.com/devnet/photoshop/sdk.html

Search there the template files you need

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