Skip to main content
Participant
March 1, 2006
Question

Exif writing error?

  • March 1, 2006
  • 4 replies
  • 758 views
Hi.

To start out, I'm a scripting newbie, so I apologize if this is something stupid or obvious.

I'm writing a script that allows me to export my ratings to the IPTC Core Keywords field (which I have working successfully), or to the EXIF data as part of the User Comment field. Basically, I'm pushing a string like "3_stars" onto the end of the field, so my ratings are portable across many applications.

So it *seems* to run fine, but when I try to view the modified image in Bridge, the Metadata/Keywords panel just has an eternally rotating "working" icon. When I right click on the image, and view File Info... > Advanced, the EXIF has the correct data in it.

The relevant portion of my code looks like:

if (thisThumb.type == 'file')
{
var src_meta = thisThumb.metadata
src_meta.namespace = "http://ns.adobe.com/xap/1.0/";
if (src_meta.Rating)
{
// create rating string
if (src_meta.Rating != '1')
{
rating = src_meta.Rating + '_stars';
}
else
{
rating = '1_star';
}
src_meta.namespace = "http://ns.adobe.com/exif/1.0/";
uc = src_meta.UserComment;
// remove old rating, if one exists
if (uc)
{
uc = uc.replace(/\d_star(s)*/,'');
}
// update EXIF
src_meta.UserComment = uc + ' ' + rating;
}
}


Am I doing something boneheaded?

(For reference, I'm running Bridge 1.0.3.107 (99784) under Windows 2000)
This topic has been closed for replies.

4 replies

dfranzen_camera_raw
Adobe Employee
Adobe Employee
June 28, 2006
With regard to EXIF properties...

Not all EXIF properties will be written back to the original files for all file types when they are set via Bridge.

And, yes, we realize that better scripting support the the XMP data model is important to our scripting customers.

Thanks for your feedback.

-David
dfranzen_camera_raw
Adobe Employee
Adobe Employee
June 28, 2006
With regard to the Lang Alt types, there is a work around for editing some of the commonly used properties, such as the Caption.

There are aliases to a number of the lang alt type Dublin Core properties in the Photoshop namespace. These aliases are registered by the XMP Toolkit used by Bridge 1.0. Setting an array property through the alias sets the first member of the array.

Below is an example of setting these properties through their Photoshop namespace aliases.

-David

if( (app.name == "bridge") ) {

var testName = "QuickTestWritePhotoshopAliasProperties";

var doQuickTest = function( thumbnailsToTest ) {
for( var t = 0; t < thumbnailsToTest.length; ++t ) {
var testThumb = thumbnailsToTest;

var md = testThumb.synchronousMetadata;

md.namespace = "http://ns.adobe.com/photoshop/1.0/";
md.Author = "Author is an alias of dc:creator"; // ordered array
md.Caption = "Caption is an alias of dc:description"; // lang alt
md.Copyright = "Copyright is an alias of xmpRights:Copyright"; // lang alt
md.Marked = "True"; // alias to xmpRights:Marked
md.Title = "Title is an alias of dc:title"; // lang alt
md.WebStatement = "WebStatement is an alias of xmpRights:WebStatement"; //simple prop

}
}

var quickTestMenuItem = MenuElement.create( "command", testName, "-at end of Tools", testName );

quickTestMenuItem.onSelect = function() {
var selectedThumbs = app.document.selections;
doQuickTest(selectedThumbs);
}
}
Participant
March 24, 2006
Thanks for the information! I guess I need to read the spec more carefully.

In this same script, I get around a similar limitation for adding keywords to XMP by generating a custom XML template, and then using applyMetadataTemplate to merge it in. Could this approach work for the EXIF data as well?

Is there any hope that a future version of Bridge will support deeper Javascript access to array-type properties?

Thanks,
___Samuel___
Participating Frequently
March 24, 2006
The eternally spinning indicator is due to a bug in Bridge. It's not yor fault.

However, there are some things you should be aware of. According to the XMP Specification, the EXIF UserComment is a Lang Alt array type property and not Text. This means that src_meta.UserComment will return an Array and not a String if you use it on files that have an EXIF UserComment already--such as one set by the camera. In that case your script will fail on uc.replace() because replace() is a String method and not an Array method. Also, since Bridge scripting does not support setting array-type properties in XMP, when your script sets the UserComment, the value is being set as a simple Text property and not Lang Alt array, which is not to spec. I reccomend finding another property where you can stick the _stars value.

-David Franzen
Adobe Bridge Quality Engineer
Adobe Systems Inc.