Skip to main content
Participant
February 12, 2008
Question

Read Metadata from a selected picture

  • February 12, 2008
  • 3 replies
  • 879 views
HI,

this will be my first script for an Adobe product. So it is very different for me. I want to read out the metadata from one or more in Bridge selected pictures. After that the metadata have to write back to an other selected picture.
This script must be made in Javascript because it must work on MAC and PC.
Could anybody of you help me ? Some code would be very helpful.

Thanks !

Sven
This topic has been closed for replies.

3 replies

Participating Frequently
November 30, 2008
Nice

Good Luck.
______
My Si tes
Participant
February 19, 2008
Hi Kasyan,

thank you for your great answer. I solved my problem with your help !

regards,

Sven
Kasyan Servetsky
Legend
February 16, 2008
Hi Sven,
I don’t know which properties you want to read and write, but I can show you a few examples:

// Read Resolution and Pixel Dimentions from selected TIF files
var sels = app.document.selections;
var mySize = "";

for (var i = 0; i < sels.length; i++){
var thumb = sels;
var md = thumb.metadata ;
md.namespace = "http://ns.adobe.com/tiff/1.0/";
mySize += thumb.displayPath + "\nResolution: " + eval(md["tiff:XResolution"])+ "x" + eval(md["tiff:YResolution"]) + "\nPixel Dimentions: " + md["tiff:ImageWidth"] + "x" + md["tiff:ImageLength"] + "\n\n";
}

alert(mySize);
// --------------------------------------------------------
// Exporting Metadata (caption information) from JPEGS to a comma separated value (CSV) file
#target bridge
if (BridgeTalk.appName == "bridge" ) {
// Let's create our menu
var menu = MenuElement.create( "command", "Export CSV File", "at the end of Tools");
menu.onSelect = function(m) {
try {
// Let's ask what the name of the output file
var f = File.saveDialog("Export file list to:", "Comma delimited file:*.CSV");
if ( !f ) { return; }
// Write the column headings
f.open("w");
f.writeln("Description,Photographer,Copyright");
// Let's get a list of all the visible thumbnails
var items = app.document.visibleThumbnails;
for (var i = 0; i < items.length; ++i) {
var item = items;
f.writeln(ListMetadata(item) );
}
f.close();
} catch(e) {}
}
} function ListMetadata(tn) {
md = tn.metadata;
md.namespace = "http://ns.adobe.com/photoshop/1.0/";
var varAuthor = md.Author + ',';
var varCopyright = md.Copyright;
md.namespace = "http://purl.org/dc/elements/1.1/";
var varDescription = md.description + ',';
return varDescription + varAuthor + varCopyright;
}
//-------------------------------------------------------
extract the date string from EXIF:DateTimeDigitized and populate the IPTC DateCreated field
http://www.adobeforums.com/webx?128@@.3bbf736e
//------------------------------------------------------
You can download Bridge CS3 SDK which has a couple examples files (SnpInspectMetadata.jsx and SnpModifyMetadata.jsx) which show how to acquire and update metadata for a selected thumbnail.
http://www.adobe.com/devnet/bridge/

Kasyan