Skip to main content
Inspiring
July 7, 2009
Question

How to tell if Bridge CS3 can modify XMP?

  • July 7, 2009
  • 1 reply
  • 1808 views

Hi Folks,

How can one tell, using a JavaScript for Bridge CS3, if XMP for a particular Thumbnail can be added or modified by Bridge? I'm currently using the sample code below from Bridge CS3's SnpModifyMetadata JavaScript to write the XMP to the Thumbnail:

    // ...SNIP...

    // xmp is a XMPMeta object, thumb is a Thumbnail object

    var updatedPacket = xmp.serialize(

       XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER |

       XMPConst.SERIALIZE_USE_COMPACT_FORMAT);

    // Have Bridge update the thumbnail's metadata.

    thumb.metadata = new Metadata(updatedPacket);

So, is there a way that a script can tell if the "thumb.metadata =" line actually knows how to add XMP to the Thumbnail before calling it? Also, if XMP can be added, what is the best way to tell if the XMP was successfully updated/added?

I know I can use the XMPFile object's canPutXMP() method from the AdobeXMPScript library, but the documentation states that Bridge can support more formats than AdobeXMPScript library can, so, since I'm using Bridge to do the update, I don't think this helps me. But maybe I'm wrong?

One more question, can Bridge add XMP to a file that doesn't already contain XMP information? I ask because the SnpModifyMetadata JavaScript file doesn't try to do anything with a thumbnail's XMP if it doesn't contain any XMP.

Thanks in advance for help!!

-- Jim

This topic has been closed for replies.

1 reply

dfranzen_camera_raw
Adobe Employee
Adobe Employee
July 7, 2009

Jim,

You can try to check the Bridge' cache's value for the canSetXmp field...

myThumbnail.core.itemContent.canSetXmp;

See the "Core infosets" section of the Bridge CS3 JavaScript reference in the SDK for more of the "capability" type info that's in the cache. You will probably get better results checking canSetXmp after you've extracted XMP from the file. Only itmes in the "immediate" infoset are set when a thumbnail are created, others may be set later. Finally, these should all be treated as read-only properties for file system Thumbnails.

In general, if you can get "pencil" icons in the Bridge metadata panel for the visual Thunbnail, then yes you should be able also set the XMP through scripting the Thumbnail object. Generally the model is...

1. Get the xmp from the file...

var md = myThumbnail.synchronousMetadata; // this will return something even if the file does not actually have XMP in it

2. Make an SXMPMeta out of it

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

3. Modify the SXMPMeta object using its API

4. Update the file...

myThumbnail.metadata = new Metadata( xmp.serialize() );

YMMV - there are some annoying restrictions on what changes actually get written into the files, and it may depend on file type. Rule of thumb is any custom XMP properties (custom namespaces) and anything that you can edit in the UI should be changable this way.

-David

Inspiring
July 7, 2009

David,

Thanks for the reply, I really appreciate it! I'll try your suggestions and report back.

Cheers!

-- Jim