The DAM Forum
Welcome, Guest. Please login or register.
September 18, 2014, 08:39:17 AM

Login with username, password and session length
Search:     Advanced search
28018 Posts in 5138 Topics by 2910 Members
Latest Member: kbroch
* Home Help Search Login Register
+  The DAM Forum
|-+  Software Discussions
| |-+  Scripting
| | |-+  using DOM to read ratings metadata from XMP side-car files
« previous next »
Pages: [1] Print
Author Topic: using DOM to read ratings metadata from XMP side-car files  (Read 4500 times)
matthewjheaney
Jr. Member
**
Posts: 52

674071051 matthewjheaney@msn.com matthewjheaney matthewjheaney
View Profile Email
« on: February 22, 2009, 01:40:25 PM »

Peter Krogh describes a technique in his book for moving ratings made in Adobe Bridge into the Expression Media (iView) catalog.  Here's the outline of a different, script-based technique that uses the DOM and an XPath expression to read the ratings element from the XMP file:

Dim objDoc, objNodeList, objNode, strVal, intVal

Set objDoc = CreateObject("MSXML2.DOMDocument.6.0")

objDoc.load(path)   'path to xmp file

objDoc.SetProperty "SelectionNamespaces", "xmlns:xmp=""http://ns.adobe.com/xap/1.0/"""

Set objNodeList = objDoc.selectNodes("//xmp:Rating")   'XPath expression
Set objNode = objNodeList(0)

strVal = objNode.nodeTypedValue
intVal = CInt(strVal)

'now intVal is in range [-1, 5]
'-1 means "reject" in Bridge CS3
'0 means "unrated"
'1-5 is actual rating

I've also done this using the XMP Toolkit SDK from Adobe.  Using the DOM and XPath expressions is probably easier, though, since I can use the DOM directly from a script.

You could incorporate this algorithm into an xMedia script to synchronize the ratings in the xMedia catalog to the ratings made in Adobe Bridge.

My next step is to be able to modify the XMP file to add (or modify) a rating.  This will allow me to sync ratings made in xMedia back into Bridge.

-Matt


Logged
matthewjheaney
Jr. Member
**
Posts: 52

674071051 matthewjheaney@msn.com matthewjheaney matthewjheaney
View Profile Email
« Reply #1 on: February 22, 2009, 01:57:01 PM »

I've also done this using the XMP Toolkit SDK from Adobe.  Using the DOM and XPath expressions is probably easier, though, since I can use the DOM directly from a script.

I should have qualified this: using the DOM is the easiest way to read metadata -- for an XMP file (because an XMP file is XML).  For other file types (e.g. PSD, JPG, etc), you'll still need to use the XMP Toolkit SDK.  My next project is to write a COM server that allows you to call the XMP Toolkit from a script.  That technique will be completely general, in the sense that it will work for any file type supported by XMP Toolkit.

-Matt
Logged
matthewjheaney
Jr. Member
**
Posts: 52

674071051 matthewjheaney@msn.com matthewjheaney matthewjheaney
View Profile Email
« Reply #2 on: February 22, 2009, 06:55:31 PM »

My next step is to be able to modify the XMP file to add (or modify) a rating.  This will allow me to sync ratings made in xMedia back into Bridge.

I just got this working too.  Here's a sketch of the algorithm:

   Set objDoc = CreateObject("MSXML2.DOMDocument.6.0")

   objDoc.load(xmppath)

   objDoc.SetProperty "SelectionNamespaces", _
                      "xmlns:xmp=""http://ns.adobe.com/xap/1.0/"""

   Set objNodeList = objDoc.selectNodes("//xmp:Rating")
   Set objNode = objNodeList(0)

   objNode.nodeTypedValue = CStr(intRating)  'assigns new ratings value
   
   objDoc.Save(xmppath)


Adobe Bridge detects that the xmp file has been modified, and automatically changes the rating it displays.

-Matt
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!