Skip to main content
Participant
January 2, 2006
Question

metadata scripting problems

  • January 2, 2006
  • 4 replies
  • 625 views
I have been working with metadata scripting for a while and I have noticed several things that don't work as I expect. Anyone know what I might be doing wrong or know whether this is just the way things work?
1. It seems that the metadata object does not support reflection, md.reflect.properies returns an invalid object.
2. Camera Raw settings can not be read, for example alert(md.Tint) shows nothing.
3. The metadata panels continue to show the old data after my script changes them. File Info... shows the changed data. Is there a way to force the panel to update?

Here is a simple script to show what I mean (1 and 2):

newMenu = new MenuElement("menu", "Meta", "after Help", "mySimpleMenu" );
theMenuItem = new MenuElement("command", "test", "at the end of mySimpleMenu", "mySimpleItem");

theMenuItem.onSelect = function()
{
md = app.document.thumbnail.metadata;

md.namespace = "http://ns.adobe.com/camera-raw-settings/1.0/";
alert("Tint = " + md.Tint);
alert("RawFileName = " + md.RawFileName);

alert("name = " + md.reflect.name);
props = md.reflect.properties;

try
{
count = props.length;
}
catch (error)
{
alert("Error: \"" + error + "\"");
}

var string = "";
for (i = 0; i < props.length; i++)
string += (props + "\n");
string += "\n";
alert(string);
}
This topic has been closed for replies.

4 replies

Known Participant
January 2, 2006
Take the ".xml" off the template name. The template name is the name of the file WITHOUT the extension.

You can get all the libraries by visiting Adobe Exchange and downloading the Import from Camera script. All three libraries are there.

Bob
Participant
January 2, 2006
Bob,

Where can I get AdobeLibrary3.jsx?
How do I call applyMetadataTemplate? The follow sample displays an error instead of applying metadata. The template works using the Bridge UI.

var doc = app.document.selections[0];
var md = doc.synchronousMetadata;
try
{
md.applyMetadataTemplate("Flenniken.xmp", "append");
}
catch (error)
{
alert("error :" + error + "\n");
}
Steve
Participant
January 2, 2006
Bob,

I noticed synchronousMetadata existed using reflect on a thumbnail and was wondering what it was for. Thanks for the tip. The panels update using it.

My example was based on the first example on page 114 of the scripting reference, it's getting the document thumbnail too. The distinction between app.document.selection[0] and app.document.thumbnail is subtle.

It's a good idea to use reflection for enumerating the valid metadata items for a scheme, but I didn't have this in mind. I was trying to figure out the parameters to applyMetadataTemplate since it wasn't working for me. It may be that it is working and just the panels are not updating, I will continue looking at it. Is there a synchronous version of this?

Using ESTK is another topic. I haven't figure how to use it yet.

Thanks.
Steve
Known Participant
January 2, 2006
Steve,

The problem here is that you are getting Bridge's document's thumbnail. The Bridge DOCUMENT is typically a folder, and will never have camera metadata.

Paste this into the ESTK, go to bridge and select an image that contains camera raw metadata, then execute the script in the ESTK. (you'll find using the ESTK's debugger is a MUCH better way to figure out what's going on than using alerts).

#target bridge

var doc = app.document.selections[0];
var md = doc.synchronousMetadata;

md.namespace = "http://ns.adobe.com/camera-raw-settings/1.0/";
$.writeln("Tint = " + md.Tint);
$.writeln( "RawFileName = " + md.RawFileName );
"Done...";

Typically you should use synchronousMetadata to get a metadata object, especially if Bridge is working on caching the folder. It was a late add and didn't make it into documentation.

I was surprised to see the metadata object doesn't provide a reflection object. I see where you were headed (getting a list of available metadata properties for a given namespace). Sadly, it is not possible to get an enumeration of all of the metadata for a given file.

I wrote some code in AdobeLibrary3.jsx that does some metadata magic for you. One of the classes, MetadataManager generates a listing of available metadata. But it's not an authoritative listing. All it does is run through the pre-defined schemas and check for metadata. Meanwhile, I included all of the schemas and all of the properties I could find.

One other major limitation:

You can only write simple types (name-value pairs). Complex metadata (keywords for example) can be read, not written. You can work around this by generating a template file and using applyMetadataTemplate().

Hope this helps

Bob
Adobe Workflow Scripting