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

Add new metadata fields

Explorer ,
Oct 25, 2011 Oct 25, 2011

Hi,

I would like to be able to add some extra metadata fields to pictures, for use in Bridge. I have heard that it is possible, but I don't understand how to do it. Can you please point me to a comprehensive guide to completing this operation or give me some pointers?

Thank you in advance.

TOPICS
Scripting
10.0K
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
Valorous Hero ,
Oct 25, 2011 Oct 25, 2011

Metatada can be added to pictures in several ways.

In Bridge metadata can be added from the Metadata panel when a picture is selected.

It can be added via File - File Info then add data using the panels

A template can be used to add metadata

Tools - Create Metadata Template

To apply to selected files...

Tools - Append/Replace Metadata

In Photoshop you can use the panels via File -File Info.

or apply a template from within the panel.

Once you have the data in the fields, this information can be extracted and used in scripts etc.

Hope this helps.

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
Explorer ,
Oct 26, 2011 Oct 26, 2011

Hi,

Thank you for answering this thread too. You've been very helpful.

I looked over the suggestions, in case I had missed something, but it seems none of them allow me to add extra fields (unless I missed something). For instance, many pictures are of products, for which I'd like to display color, make or even materials used and I'd like to be able to add the appropriate fields to the already existing ones. Can this be done through Bridge directly or does it have to be scripted in order for Bridge to even allow this?

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
Valorous Hero ,
Oct 26, 2011 Oct 26, 2011

To add custom fields a script or panel would have to be created.

There is an example of adding fields in SnpModifyMetadata.jsx in the Bridge SDK

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

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
Explorer ,
Oct 26, 2011 Oct 26, 2011

Is this the snippet of code you were referring to?

  // Create a structure and add some fields

                    xmp.setProperty("http://ns.adobe.com/xap/1.0/t/pg/", "MaxPageSize", "", XMPConst.PROP_IS_STRUCT);

                    xmp.setStructField("http://ns.adobe.com/xap/1.0/t/pg/", "MaxPageSize", XMPConst.TYPE_DIMENSIONS, "w", 8.5);

                    xmp.setStructField("http://ns.adobe.com/xap/1.0/t/pg/", "MaxPageSize", XMPConst.TYPE_DIMENSIONS, "h", 12);

                    xmp.setStructField("http://ns.adobe.com/xap/1.0/t/pg/", "MaxPageSize", XMPConst.TYPE_DIMENSIONS, "unit", "inches");

 

                    // Create a custom structure and add some fields

                    xmp.setProperty(XMPConst.NS_DC, "sdknames", "", XMPConst.PROP_IS_STRUCT);

                    xmp.setStructField(XMPConst.NS_DC, "sdknames", sdkNamespace2, "sdkfld1", "Tom");

                    xmp.setStructField(XMPConst.NS_DC, "sdknames", sdkNamespace2, "sdkfld2", "Dick");

                    xmp.setStructField(XMPConst.NS_DC, "sdknames", sdkNamespace2, "sdkfld3", "Harry");

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
Valorous Hero ,
Oct 26, 2011 Oct 26, 2011

It does need a bit more code than that.

I will see if I can put a working example together.

Back soon....

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
Valorous Hero ,
Oct 26, 2011 Oct 26, 2011

Ok here is an example, you can see if it works for you....

Copy and paste the script into ExtendScript Toolkit
This gets installed with Photoshop and can be found:-
PC: C:\Program Files\Adobe\Adobe Utilities
MAC: <hard drive>/Applications/Utilities/Adobe Utilities

Start Bridge
PC: Edit - Preferences - Startup Scripts
Mac: Adobe Bridge menu - Preferences - Startup Scripts
At the bottom click the "Reveal Button" this will open the folder where the script should be saved.
Close and restart Bridge.
Accept the new script.


To use:
Select the document in Bridge and in the context menu (right mouse click) select "Add/Show Custom MetaData"

#target bridge  

   if( BridgeTalk.appName == "bridge" ) { 

customMetaData = MenuElement.create("command", "Add/Show Custom MetaData", "at the end of Thumbnail");

}

customMetaData.onSelect = function () {

var win= new Window('dialog','Custom Metadata');

win.pnl1 = win.add('panel', undefined, undefined, {borderStyle:"black"});

win.grp5 = win.pnl1.add('group');

win.grp5.title = win.grp5.add('statictext',undefined,'Add Custom Data');

win.grp5.title.graphics.font = ScriptUI.newFont("Georgia","BOLDITALIC",20);

win.grp10 = win.pnl1.add('group');

win.grp10.alignment='left';

win.grp10.st1 = win.grp10.add('statictext',undefined,"Colour");

win.grp10.st1.preferredSize=[80,20];

win.grp10.et1 = win.grp10.add('edittext');

win.grp10.et1.preferredSize=[100,20];

win.grp20 = win.pnl1.add('group');

win.grp20.alignment='left';

win.grp20.st1 = win.grp20.add('statictext',undefined,"Make");

win.grp20.st1.preferredSize=[80,20];

win.grp20.et1 = win.grp20.add('edittext');

win.grp20.et1.preferredSize=[200,20];

win.grp30 = win.pnl1.add('group');

win.grp30.alignment='left';

win.grp30.st1 = win.grp30.add('statictext',undefined,"Materials");

win.grp30.st1.preferredSize=[80,20];

win.grp30.et1 = win.grp30.add('edittext');

win.grp30.et1.preferredSize=[200,20];

win.grp40 = win.pnl1.add('group');

win.grp40.alignment='left';

win.grp40.st1 = win.grp40.add('statictext',undefined,'Show existing data if existing');

win.grp40.st1.preferredSize=[180,20];

win.grp40.bu1 = win.grp40.add('button',undefined,'Get Data');

win.grp300 = win.pnl1.add('group');

win.grp300.bu1 = win.grp300.add('button',undefined,'Set Data');

win.grp300.bu1.preferredSize=[100,30];

win.grp300.bu2 = win.grp300.add('button',undefined,'Cancel');

win.grp300.bu2.preferredSize=[100,30];

win.grp40.bu1.onClick=function(){

if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var thumb = app.document.selections[0];

var md = thumb.synchronousMetadata;

var xmp = new XMPMeta(md.serialize());

var sdkNamespace = "http://durannarud.custom.data/";

var sdkPrefix = "duran:";

XMPMeta.registerNamespace(sdkNamespace, sdkPrefix);

var Colour = "'" + xmp.getProperty(sdkNamespace, "Colour") + "'";

if(Colour == '' || Colour == undefined){

    win.grp10.et1.text='None';

    }else{

        win.grp10.et1.text=Colour.replace(/^'/,'').replace(/'$/,'');

         if(win.grp10.et1.text=='undefined' ) win.grp10.et1.text='None';

        }

var Make = "'" + xmp.getProperty(sdkNamespace, "Make") + "'";

if(Make == '' || Make == undefined){

    win.grp20.et1.text='None';

    }else{

        win.grp20.et1.text=Make.replace(/^'/,'').replace(/'$/,'');

        if(win.grp20.et1.text=='undefined' ) win.grp20.et1.text='None';

        }

var Materials  = "'" + xmp.getProperty(sdkNamespace, "Materials") + "'";

if(Materials == '' || Materials == undefined){

    win.grp30.et1.text='None';

    }else{

        win.grp30.et1.text=Materials.replace(/^'/,'').replace(/'$/,'');

        if(win.grp30.et1.text=='undefined' ) win.grp30.et1.text='None';

        }

    }

win.grp300.bu1.onClick=function(){

    if(win.grp10.et1.text=='' || win.grp10.et1.text =='None'){

        alert("No Colour has been entered!");

        return;

        }

        if(win.grp20.et1.text=='' || win.grp20.et1.text =='None'){

        alert("No Make has been entered!");

        return;

        }

        if(win.grp30.et1.text=='' || win.grp30.et1.text =='None'){

        alert("No Materials have been entered!");

        return;

        }

win.close(0);

if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var thumb = app.document.selections[0];

var md = thumb.synchronousMetadata;

var xmp = new XMPMeta(md.serialize());

var sdkNamespace = "http://durannarud.custom.data/";

var sdkPrefix = "duran:";

XMPMeta.registerNamespace(sdkNamespace, sdkPrefix);

xmp.setProperty(sdkNamespace, "Colour", win.grp10.et1.text);

xmp.setProperty(sdkNamespace, "Make", win.grp20.et1.text);

xmp.setProperty(sdkNamespace, "Materials", win.grp30.et1.text);

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

thumb.metadata = new Metadata(updatedPacket);

    }

win.center();

win.show();

}

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
Explorer ,
Oct 27, 2011 Oct 27, 2011

Hi Paul,

Thanks again. Curiously, this one doesn't seem to work. I followed the steps, but for some reason the context menu doesn't show the "Add/Show Custom MetaData" option. It does load the script though. Could this be related to the version of Bridge? I'm on 5.1 here.

PS: I can't get over the fact you coded this whole thing in less than 1 hour.

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
Valorous Hero ,
Oct 27, 2011 Oct 27, 2011

Hi, I am using Bridge version is 4.0.5.1, Bridge 5.1 should not exist as the Bridge version start with 1 less than the CS version.

It might be an idea to just change one line to put the script in the Tools menu, to do this...

Change:-

customMetaData = MenuElement.create("command", "Add/Show Custom MetaData", "at the end of Thumbnail");

To:

customMetaData = MenuElement.create("command", "Add/Show Custom MetaData", "at the end of Tools");

As you can see it just changes Thumbnail to Tools, and should then put the script at the bottom of the Tools Menu.

It is a very basic script that can be modified to add other fields if required.

Please let me know if it works with this change.

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
Valorous Hero ,
Oct 27, 2011 Oct 27, 2011

This version might be better, this should bring up any fields that exits without asking for them...

#target bridge  
   if( BridgeTalk.appName == "bridge" ) { 
customMetaData = MenuElement.create("command", "Add-Show Custom MetaData", "at the end of Tools");
}
customMetaData.onSelect = function () {
var win= new Window('dialog','Custom Metadata');
win.pnl1 = win.add('panel', undefined, undefined, {borderStyle:"black"});
win.grp5 = win.pnl1.add('group');
win.grp5.title = win.grp5.add('statictext',undefined,'Add Custom Data');
win.grp5.title.graphics.font = ScriptUI.newFont("Georgia","BOLDITALIC",20);
win.grp10 = win.pnl1.add('group');
win.grp10.alignment='left';
win.grp10.st1 = win.grp10.add('statictext',undefined,"Colour");
win.grp10.st1.preferredSize=[80,20];
win.grp10.et1 = win.grp10.add('edittext');
win.grp10.et1.preferredSize=[100,20];
win.grp20 = win.pnl1.add('group');
win.grp20.alignment='left';
win.grp20.st1 = win.grp20.add('statictext',undefined,"Make");
win.grp20.st1.preferredSize=[80,20];
win.grp20.et1 = win.grp20.add('edittext');
win.grp20.et1.preferredSize=[200,20];
win.grp30 = win.pnl1.add('group');
win.grp30.alignment='left';
win.grp30.st1 = win.grp30.add('statictext',undefined,"Materials");
win.grp30.st1.preferredSize=[80,20];
win.grp30.et1 = win.grp30.add('edittext');
win.grp30.et1.preferredSize=[200,20];

win.grp300 = win.pnl1.add('group');
win.grp300.bu1 = win.grp300.add('button',undefined,'Set Data');
win.grp300.bu1.preferredSize=[150,30];
win.grp300.bu2 = win.grp300.add('button',undefined,'Cancel');
win.grp300.bu2.preferredSize=[150,30];

if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var thumb = app.document.selections[0];
var md = thumb.synchronousMetadata;
var xmp = new XMPMeta(md.serialize());
var sdkNamespace = "http://durannarud.custom.data/";
var sdkPrefix = "duran:";
XMPMeta.registerNamespace(sdkNamespace, sdkPrefix);
var Colour = "'" + xmp.getProperty(sdkNamespace, "Colour") + "'";
if(Colour == '' || Colour == undefined){
    win.grp10.et1.text='None';
    }else{
        win.grp10.et1.text=Colour.replace(/^'/,'').replace(/'$/,'');
         if(win.grp10.et1.text=='undefined' ) win.grp10.et1.text='None';
        }
var Make = "'" + xmp.getProperty(sdkNamespace, "Make") + "'";
if(Make == '' || Make == undefined){
    win.grp20.et1.text='None';
    }else{
        win.grp20.et1.text=Make.replace(/^'/,'').replace(/'$/,'');
        if(win.grp20.et1.text=='undefined' ) win.grp20.et1.text='None';
        }
var Materials  = "'" + xmp.getProperty(sdkNamespace, "Materials") + "'";
if(Materials == '' || Materials == undefined){
    win.grp30.et1.text='None';
    }else{
        win.grp30.et1.text=Materials.replace(/^'/,'').replace(/'$/,'');
        if(win.grp30.et1.text=='undefined' ) win.grp30.et1.text='None';
        }

win.grp300.bu1.onClick=function(){
    if(win.grp10.et1.text=='' || win.grp10.et1.text =='None'){
        alert("No Colour has been entered!");
        return;
        }
        if(win.grp20.et1.text=='' || win.grp20.et1.text =='None'){
        alert("No Make has been entered!");
        return;
        }
        if(win.grp30.et1.text=='' || win.grp30.et1.text =='None'){
        alert("No Materials have been entered!");
        return;
        }
win.close(0);
if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var thumb = app.document.selections[0];
var md = thumb.synchronousMetadata;
var xmp = new XMPMeta(md.serialize());
var sdkNamespace = "http://durannarud.custom.data/";
var sdkPrefix = "duran:";
XMPMeta.registerNamespace(sdkNamespace, sdkPrefix);
xmp.setProperty(sdkNamespace, "Colour", win.grp10.et1.text);
xmp.setProperty(sdkNamespace, "Make", win.grp20.et1.text);
xmp.setProperty(sdkNamespace, "Materials", win.grp30.et1.text);
var updatedPacket = xmp.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
thumb.metadata = new Metadata(updatedPacket);
    }
win.center();
win.show();
}

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
Explorer ,
Oct 28, 2011 Oct 28, 2011

Hi Paul,

I tried this new version and it works perfectly fine when applied to one image at a time. When I tried to treat more than one image, none of them seemed to have picked up the change. Is there a way to use this as a template?

Thanks!

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
Valorous Hero ,
Oct 28, 2011 Oct 28, 2011

Yes that script will only work on the first document in the selection.

It might be best to have another script that will apply the same metadata to all selected documents. Then you could use the first script to check what the metadata is set to and change if required.

This script will update all selected documents....

#target bridge  
   if( BridgeTalk.appName == "bridge" ) { 
setCustomMetaData = MenuElement.create("command", "Add Custom MetaData", "at the end of Tools");
}
setCustomMetaData.onSelect = function () {
var win= new Window('dialog','Custom Metadata');
win.pnl1 = win.add('panel', undefined, undefined, {borderStyle:"black"});
win.grp5 = win.pnl1.add('group');
win.grp5.title = win.grp5.add('statictext',undefined,'Add Custom Data');
win.grp5.title.graphics.font = ScriptUI.newFont("Georgia","BOLDITALIC",20);
win.grp10 = win.pnl1.add('group');
win.grp10.alignment='left';
win.grp10.st1 = win.grp10.add('statictext',undefined,"Colour");
win.grp10.st1.preferredSize=[80,20];
win.grp10.et1 = win.grp10.add('edittext');
win.grp10.et1.preferredSize=[100,20];
win.grp20 = win.pnl1.add('group');
win.grp20.alignment='left';
win.grp20.st1 = win.grp20.add('statictext',undefined,"Make");
win.grp20.st1.preferredSize=[80,20];
win.grp20.et1 = win.grp20.add('edittext');
win.grp20.et1.preferredSize=[200,20];
win.grp30 = win.pnl1.add('group');
win.grp30.alignment='left';
win.grp30.st1 = win.grp30.add('statictext',undefined,"Materials");
win.grp30.st1.preferredSize=[80,20];
win.grp30.et1 = win.grp30.add('edittext');
win.grp30.et1.preferredSize=[200,20];

win.grp300 = win.pnl1.add('group');
win.grp300.bu1 = win.grp300.add('button',undefined,'Set Data');
win.grp300.bu1.preferredSize=[150,30];
win.grp300.bu2 = win.grp300.add('button',undefined,'Cancel');
win.grp300.bu2.preferredSize=[150,30];

win.grp300.bu1.onClick=function(){
    if(win.grp10.et1.text==''){
        alert("No Colour has been entered!");
        return;
        }
        if(win.grp20.et1.text==''){
        alert("No Make has been entered!");
        return;
        }
        if(win.grp30.et1.text==''){
        alert("No Materials have been entered!");
        return;
        }
win.close(0);
if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var sels = app.document.selections;
for(var a in sels){
var thumb = sels;
var md = thumb.synchronousMetadata;
var xmp = new XMPMeta(md.serialize());
var sdkNamespace = "
http://durannarud.custom.data/";
var sdkPrefix = "duran:";
XMPMeta.registerNamespace(sdkNamespace, sdkPrefix);
xmp.setProperty(sdkNamespace, "Colour", win.grp10.et1.text);
xmp.setProperty(sdkNamespace, "Make", win.grp20.et1.text);
xmp.setProperty(sdkNamespace, "Materials", win.grp30.et1.text);
var updatedPacket = xmp.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
thumb.metadata = new Metadata(updatedPacket);
}
    }
win.center();
win.show();
}

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
Explorer ,
Oct 28, 2011 Oct 28, 2011

Thanks! This works great in tandem with the first.

Is it possible to add metadata without having to fill in all the fields? Sometimes the metadata does not apply everywhere; also, some pictures will share only some of the metadata, while sharing other metadata with other images. For instance:

                Meta1     Meta2     Meta3

Image1         h            q            w

Image2         x            y            w

Image3         x            q            n

So basically there could be three rounds of group metadata additions here, but this could not be doable if all fieldsare mandatory when you make an update.

I was also wondering, seeing as this metadata is only visible once Bridge has the right script, would the Photoshop script (on a similar Indesign script) you showed me before, for inatsnce, be able to detect this data and output it without having a script installed specifically for these fields?

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
Valorous Hero ,
Oct 28, 2011 Oct 28, 2011

I have now modified the script so that it will allow you to update the selected documents with any one or all fields filled in.

The script to create the catalogues can be modified to extract the metadata and put the information on the page.

If this is what you want, would the metadata be extracted from just the one document (the big picture) if so would all three fields be concatonated or would you like three seperate lines?

#target bridge  
   if( BridgeTalk.appName == "bridge" ) { 
setCustomMetaData = MenuElement.create("command", "Add Custom MetaData", "at the end of Tools");
}
setCustomMetaData.onSelect = function () {
var win= new Window('dialog','Custom Metadata');
win.pnl1 = win.add('panel', undefined, undefined, {borderStyle:"black"});
win.grp5 = win.pnl1.add('group');
win.grp5.title = win.grp5.add('statictext',undefined,'Add Custom Data');
win.grp5.title.graphics.font = ScriptUI.newFont("Georgia","BOLDITALIC",20);
win.grp10 = win.pnl1.add('group');
win.grp10.alignment='left';
win.grp10.st1 = win.grp10.add('statictext',undefined,"Colour");
win.grp10.st1.preferredSize=[80,20];
win.grp10.et1 = win.grp10.add('edittext');
win.grp10.et1.preferredSize=[100,20];
win.grp20 = win.pnl1.add('group');
win.grp20.alignment='left';
win.grp20.st1 = win.grp20.add('statictext',undefined,"Make");
win.grp20.st1.preferredSize=[80,20];
win.grp20.et1 = win.grp20.add('edittext');
win.grp20.et1.preferredSize=[200,20];
win.grp30 = win.pnl1.add('group');
win.grp30.alignment='left';
win.grp30.st1 = win.grp30.add('statictext',undefined,"Materials");
win.grp30.st1.preferredSize=[80,20];
win.grp30.et1 = win.grp30.add('edittext');
win.grp30.et1.preferredSize=[200,20];

win.grp300 = win.pnl1.add('group');
win.grp300.bu1 = win.grp300.add('button',undefined,'Set Data');
win.grp300.bu1.preferredSize=[150,30];
win.grp300.bu2 = win.grp300.add('button',undefined,'Cancel');
win.grp300.bu2.preferredSize=[150,30];
win.grp300.bu1.onClick=function(){
win.close(0);
if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var sels = app.document.selections;
for(var a in sels){
var thumb = sels;
var md = thumb.synchronousMetadata;
var xmp = new XMPMeta(md.serialize());
var sdkNamespace = "
http://durannarud.custom.data/";
var sdkPrefix = "duran:";
XMPMeta.registerNamespace(sdkNamespace, sdkPrefix);
var updateMetadata = false;
if(win.grp10.et1.text !=''){
    updateMetadata = true;
    xmp.setProperty(sdkNamespace, "Colour", win.grp10.et1.text);
    }
if(win.grp20.et1.text !='') {
    updateMetadata = true;
    xmp.setProperty(sdkNamespace, "Make", win.grp20.et1.text);
    }
if(win.grp30.et1.text !=''){
    updateMetadata = true;
    xmp.setProperty(sdkNamespace, "Materials", win.grp30.et1.text);
    }
if(updateMetadata){
var updatedPacket = xmp.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
thumb.metadata = new Metadata(updatedPacket);
}
}
    }
win.center();
win.show();
}

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
Explorer ,
Oct 29, 2011 Oct 29, 2011

Thank you. I tested it and it works well!

I think the metadata should be extracted from 1.jpg and if I need to extract further data from the other pictures, I could just copy the extraction code from the initial picture and apply it to the others too. Or do you think that's unlikely to work?

I was also wondering if there is a guide for adding styling in the script. For instance, borders around the pictures, or underlined text, etc. This is not set in stone, so a guide for the code would be the most appropriate option, in case I need to mix and match styles.

I was looking through the scipts to try to understand a bit how it works and I came accross those two lines mentioning my screen name:

var sdkNamespace = "http://durannarud.custom.data/";
var sdkPrefix = "duran:";

What do they do?

Thanks again and have a nice weekend!

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
Valorous Hero ,
Oct 29, 2011 Oct 29, 2011

For documentation it can be found in the Application scripting folder:-

Photoshop CS5 JavaScript Ref.pdf

C:\Program Files\Adobe\Adobe Photoshop CS5 (64 Bit)\Scripting\Documents

Adding a border around the pictures would be better using a stoke on the inside, I will add an example.

All effects for layers require ScriptListner generated code.

var sdkNamespace = "http://durannarud.custom.data/";

This line is adding a new schema to the document and can be anything, but need to be unique and used to add and retrieve data.


var sdkPrefix = "duran:";

This sets the prefix of the fields.

If you have a look at the file info and select the Advanced tab you will see the different schemas including yours if data has been added.

I will have post some more code tomorrow so that you can see the difference.

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
Valorous Hero ,
Oct 29, 2011 Oct 29, 2011

I had a bit of spare time so please try this modified Photoshop script.

#target Photoshop
app.bringToFront();
main();
function main(){
var folderList=[];
topLevelFolder = Folder.selectDialog("Please select the source folder");
folderList = findAllFolders( topLevelFolder, folderList);
for(var z in folderList){
var file1 = File(folderList +"/1.jpg");
var file2 = File(folderList +"/2.jpg");
var file3 = File(folderList +"/3.jpg");
var file4 = File(folderList +"/4.jpg");
if(!file1.exists) continue;
if(!file2.exists) continue;
if(!file3.exists) continue;
if(!file4.exists) continue;
//---------------------------- FolderName, Where do you want the name getting from? , Stoke layer(true/false), Number of Pixels
createTemplate(decodeURI(folderList.name),"Name",true,15);
fillMask("Big", file1);
var Result = eval(getXMP(file1)); // Get Metadata from File1
if(Result[0].toString() != "undefined" && Result[0].toString() != '' ) addTextLayer("Colour","Colour : " +Result[0].toString(),178,2300);
if(Result[1].toString() != "undefined" && Result[1].toString() != '' ) addTextLayer("Make","Make : " + Result[1].toString(),178,2400);
if(Result[2].toString() != "undefined" && Result[2].toString() != '' ) addTextLayer("Material","Materials : " + Result[2].toString(),178,2500);

fillMask("topSquare", file2);
fillMask("middleSquare", file3);
fillMask("bottomSquare", file4);
var saveFile= File(folderList +"/"+ decodeURI(folderList.name) + ".psd");
SavePSD(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
}
function fillMask(layerToSelect, sFile){
var FillColor = new SolidColor;
FillColor.rgb.hexValue = 'ff00f0';
var docRef=activeDocument;
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
docRef.activeLayer = app.activeDocument.activeLayer;
var layerName = app.activeDocument.activeLayer.name;
app.activeDocument = docRef; 
selectLayerMask(layerToSelect);
unSelectMask();
docRef.selection.selectAll();
docRef.selection.fill(FillColor);
docRef.selection.deselect();
waitForRedraw();
selectLayerMask(layerToSelect);
var LB = activeDocument.activeLayer.bounds;
var res = activeDocument.resolution;
var width = LB[2]-LB[0];
var height = LB[3]-LB[1];
open(File(sFile));
var layerFullName = decodeURI(activeDocument.fullName);
var dwidth = activeDocument.width.value;
var dheight = activeDocument.height.value;  
var ratio = height/width;
var dratio = dheight/dwidth;
if (dratio > ratio) {  height = undefined; } else { width = undefined; }
activeDocument.resizeImage(width, height, res, ResampleMethod.BICUBICSHARPER);
activeDocument.flatten();
activeDocument.selection.selectAll();
activeDocument.selection.copy();
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
activeDocument = docRef;
selArea();
try{executeAction(charIDToTypeID( "CpFX" ), undefined, DialogModes.NO );}catch(e){}
docRef.paste(true);
try{executeAction( charIDToTypeID( "PaFX" ), undefined, DialogModes.NO );}catch(e){}
linkLayer();
activeDocument.activeLayer.name=decodeURI(sFile.name);
selectLayerMask (layerToSelect);
activeDocument.activeLayer.remove();
$.gc();
app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
}
function createTemplate(Category,cName,StrokeLayer,Pixels){
var strtRulerUnits = app.preferences.rulerUnits;      
var strtTypeUnits = app.preferences.typeUnits;      
app.preferences.rulerUnits = Units.PIXELS;      
app.preferences.typeUnits = TypeUnits.PIXELS;
var doc = app.documents.add(3300, 2550, 300, "Template", NewDocumentMode.RGB, DocumentFill.WHITE);
var LB=[176,451,1928,2202];
MakeLayerMask("Big",LB[0],LB[1],LB[2],LB[3],0);
if(StrokeLayer) Stroke(Number(Pixels));
LB=[1968,451,2528,1009];
MakeLayerMask("topSquare",LB[0],LB[1],LB[2],LB[3],0);
if(StrokeLayer) Stroke(Number(Pixels));
LB=[1968,1049,2528,1607];
MakeLayerMask("middleSquare",LB[0],LB[1],LB[2],LB[3],0);
if(StrokeLayer) Stroke(Number(Pixels));
LB=[1968,1642,2528,2202];
MakeLayerMask("bottomSquare",LB[0],LB[1],LB[2],LB[3],0);
if(StrokeLayer) Stroke(Number(Pixels));
addTextLayer("Cat",Category,178,220,true,true); //Underline and Bold
addTextLayer("Name",cName,178,308);
//addTextLayer("Other","Other Fields",178,2334);
app.preferences.rulerUnits = strtRulerUnits; 
app.preferences.typeUnits = strtTypeUnits;
}
function MakeLayerMask(LayerName,Left,Top,Right,Bottom,Feather){
var Colour = new SolidColor;
Colour.rgb.hexValue = 'CACACA';
    activeDocument.selection.select([[Left,Top],[Right,Top],[Right,Bottom],[Left,Bottom]], SelectionType.REPLACE,Feather, false);
  activeDocument.artLayers.add();
activeDocument.selection.fill(Colour);
    addMask();
activeDocument.activeLayer.name = LayerName;
}
function addMask(){
    var desc = new ActionDescriptor();
    desc.putClass( charIDToTypeID('Nw  '), charIDToTypeID('Chnl') );
        var ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Msk ') );
    desc.putReference( charIDToTypeID('At  '), ref );
    desc.putEnumerated( charIDToTypeID('Usng'), charIDToTypeID('UsrM'), charIDToTypeID('RvlS') );
    executeAction( charIDToTypeID('Mk  '), desc, DialogModes.NO );
}
function addTextLayer(layerName,newText,X,Y,Underline,Bold) {
      var thisLayer = activeDocument.artLayers.add();
      thisLayer.kind = LayerKind.TEXT;
      thisLayer.name = layerName;
      var textProperty = thisLayer.textItem;
      textProperty.size = 16;
      textProperty.font = "Georgia";
      var newColor = new SolidColor();
      newColor.rgb.red = 0;
      newColor.rgb.green = 0;
      newColor.rgb.blue = 0;
      textProperty.color = newColor;
      textProperty.position = new Array( X,Y);
      thisLayer.blendMode = BlendMode.NORMAL;
      thisLayer.opacity = 100;
      textProperty.contents = newText;
      if(Underline) textProperty.underline=UnderlineType.UNDERLINERIGHT;
      if(Bold) textProperty.fauxBold=true;
};
function selectLayerMask (LayerName) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Msk " ) );
ref.putName( charIDToTypeID( "Lyr " ), LayerName );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putBoolean( charIDToTypeID( "MkVs" ), false );
executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
};
function selArea(){
var desc467 = new ActionDescriptor();
        var ref331 = new ActionReference();
        ref331.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') );
    desc467.putReference( charIDToTypeID('null'), ref331 );
        var ref332 = new ActionReference();
        ref332.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc467.putReference( charIDToTypeID('T   '), ref332 );
    executeAction( charIDToTypeID('setd'), desc467, DialogModes.NO );
};
function linkLayer(){
   var desc460 = new ActionDescriptor();
        var ref42 = new ActionReference();
        ref42.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc460.putReference( charIDToTypeID('null'), ref42 );
        var desc461 = new ActionDescriptor();
        desc461.putBoolean( charIDToTypeID('Usrs'), true );
    desc460.putObject( charIDToTypeID('T   '), charIDToTypeID('Lyr '), desc461 );
    executeAction( charIDToTypeID('setd'), desc460, DialogModes.NO );
};
function unSelectMask() {
    var desc28 = new ActionDescriptor();
        var ref14 = new ActionReference();
        ref14.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('RGB ') );
    desc28.putReference( charIDToTypeID('null'), ref14 );
    desc28.putBoolean( charIDToTypeID('MkVs'), false );
    executeAction( charIDToTypeID('slct'), desc28, DialogModes.NO );
};
function waitForRedraw() {
  var desc = new ActionDescriptor();
  desc.putEnumerated(charIDToTypeID("Stte"), charIDToTypeID("Stte"), charIDToTypeID("RdCm"));
  executeAction(charIDToTypeID("Wait"), desc, DialogModes.NO);
};
function findAllFolders( srcFolderStr, destArray) {
var fileFolderArray = Folder( srcFolderStr ).getFiles();
for ( var i = 0; i < fileFolderArray.length; i++ ) {
  var fileFoldObj = fileFolderArray;
  if ( fileFoldObj instanceof File ) {  
  } else {
         destArray.push( Folder(fileFoldObj) );
  findAllFolders( fileFoldObj.toString(), destArray );
  }
}
return destArray;
};
function SavePSD(saveFile){
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true; 
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
}
function Stroke(Pixels,R,G,B){
if(R == undefined) R =0;
if(G == undefined) G =0;
if(B == undefined) B =0;
cTID = function(s) { return app.charIDToTypeID(s); };
   var desc205 = new ActionDescriptor();
        var ref149 = new ActionReference();
        ref149.putProperty( cTID('Prpr'), cTID('Lefx') );
        ref149.putEnumerated( cTID('Lyr '), cTID('Ordn'), cTID('Trgt') );
    desc205.putReference( cTID('null'), ref149 );
        var desc206 = new ActionDescriptor();
        desc206.putUnitDouble( cTID('Scl '), cTID('#Prc'), 416.666667 );
            var desc207 = new ActionDescriptor();
            desc207.putBoolean( cTID('enab'), true );
            desc207.putEnumerated( cTID('Styl'), cTID('FStl'), cTID('InsF') );
            desc207.putEnumerated( cTID('PntT'), cTID('FrFl'), cTID('SClr') );
            desc207.putEnumerated( cTID('Md  '), cTID('BlnM'), cTID('Nrml') );
            desc207.putUnitDouble( cTID('Opct'), cTID('#Prc'), 100.000000 );
            desc207.putUnitDouble( cTID('Sz  '), cTID('#Pxl'), Pixels );
                var desc208 = new ActionDescriptor();
                desc208.putDouble( cTID('Rd  '), R );
                desc208.putDouble( cTID('Grn '), G );
                desc208.putDouble( cTID('Bl  '), B );
            desc207.putObject( cTID('Clr '), cTID('RGBC'), desc208 );
        desc206.putObject( cTID('FrFX'), cTID('FrFX'), desc207 );
    desc205.putObject( cTID('T   '), cTID('Lefx'), desc206 );
    executeAction( cTID('setd'), desc205, DialogModes.NO );
}
function getXMP(fileName){
var mData=[];
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
var xmpf = new XMPFile(fileName.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);
var xmp = xmpf.getXMP();
try{
var Colour ="'" + xmp.getProperty( "http://durannarud.custom.data/", "Colour") + "'";
var Make= "'" + xmp.getProperty( "http://durannarud.custom.data/", "Make") + "'";
var Materials = +"'" + xmp.getProperty( "http://durannarud.custom.data/", "Materials") + "'";
if(Colour == '') {
    mData.push("N/A");
    }else{
        mData.push(Colour.replace(/^'/,'').replace(/NaN/,'').replace(/'$/,''));
        }
if(Make == '') {
    mData.push("N/A");
    }else{
        mData.push(Make.replace(/^'/,'').replace(/NaN/,'').replace(/'$/,''));
        }
if(Materials == '') {
    mData.push("N/A");
    }else{
        mData.push(Materials.replace(/^'/,'').replace(/NaN/,'').replace(/'$/,''));
        }
return mData.toSource();
}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
Explorer ,
Oct 31, 2011 Oct 31, 2011

Hi Paul,

Thanks for the updated script. I just tried it out, but it doesn't seem to work. It does create three text layers with the names of the metadata fields, but nothing is shown in them (I didn't forget to prep the files in Bridge in advance).

I'm not sure if this is of any importance (may simply be coincidental), but I'm reporting just in case: whereas the original script was very swift, this one took a very, very long time to render and swelled the pagefile size considerably; about 4 gigs to be exact (the original hand't).

I was also curious regarding this line: createTemplate(decodeURI(folderList.name),"MyName"); from the initial script.  I can't get it to display anything other than "MyName" or the equivalent "Name" in the new script. I tried single folder and folder within folder. Which folder information is it picking up?

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
Explorer ,
Oct 31, 2011 Oct 31, 2011

I modified both of the original Bridge scripts to accommodate new metadate fields.

I was also wondering if the info here http://gunar.wordpress.com/2010/05/19/create-custom-metadata-panels-in-cs5-with-xml/ is what I would need in order to have the new metadata fields displayed in the Metadata tab in Bridge. I like the idea of being able to see the new data there if this is all it would take to do it.

The other thing I had in mind is to add a shortcut to the scripts. If I have 200 different pictures to treat, it would save time if I didn't have to go Tools -> Add Custom Metadata every time. Is this possible to do this in the JSX file or is it done somewhere else?

EDIT2:

Can I use these scripts on my Mac too?

EDIT1:

Tough luck on the keyboard shortcut... It seems it's not possible in Bridge. Only this would work, but it's a Mac-only solution:

InDesign, Photoshop and Illustrator all let you add custom keyboard shortcuts using the Edit > Keyboard Shortcuts command. Unfortunately, Bridge doesn't have such a command. If you use a Mac, there is a neat way to add keyboard shortcuts to Bridge menu items. As pointed out by a reader a few days ago, you can use an OS X Preference setting to do this. Here's how:

1. Launch an application that you want to add a keyboard shortcut to. Choose the menu command that you want to add a shortcut to, and write down the exact spelling of item the way it appears in the menu. If I wanted to add a shortcut to the File > Place > In Photoshop command in Bridge, I would write down In Photoshop.

2. Go to your Mac OS X System Preferences, and click on the Keyboard & Mouse preference.

3. Click on the Keyboard Shortcuts category at the top of the dialog box.

4. Click on the plus sign in the lower-left corner of the dialog box to add a keyboard shortcut.

5. For the "Application", choose your application if it is listed in the drop down menu, or choose Other at the bottom of the list and browse to find your application.

6. For the "Menu Title" type the exact name of the command you wrote down in step one.

7. Place your cursor in the "Keyboard Shortcut" field, and type the keyboard shortcut you want to assign. Be sure to choose a unique shortcut that is not already in use by the application or OS X.

8. Click the Add button, and you're finished!

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
Guest
Sep 24, 2018 Sep 24, 2018
LATEST

can these be undone without uninstalling?

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 ,
Feb 07, 2016 Feb 07, 2016

Try the following (it works for me in Bridge CS6):

Re: Re: Custom Info Panel as Bridge MetaData Panel

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