• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can I automate the writing of XMP metadata into JPEG and TIFF files?

New Here ,
Oct 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

I have written an ASP.NET 3.5 website application on behalf of an annual international photographic competition. Entrants will be uploading digital photos in either JPEG or TIFF format. Ideally, I would write entrant identity and image title information into the XMP metadata for each image immediately after upload - but so far, I have failed to find any way to do this in ASP.NET.

Thousands of images are involved, so I need to find a way to automate the metadata insertion, perhaps with some sort of script that uses a text file (extracted from the SQL Server database on my website) as the source of the metadata for a batch of images. Is this the sort of task that can be done by writing a script for Bridge CS3? Are there any scripts already in existence that I could use? I am a total beginner in this area.

I use a Win XP PC, though I have a colleague who, I think, has CS3 on his Mac (running under the Leopard OS), so scripts for either platform might be usable.

David
TOPICS
Scripting

Views

9.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
replies 104 Replies 104
Community Beginner ,
Oct 30, 2009 Oct 30, 2009

Copy link to clipboard

Copied

Hi Paul,

Thanks for the great scripts. I can use this and your import kewords script to automate quite a bit of data entry.

How can the metadata import fields be changed? I would like to be able to import data into a couple more fields but don't know much about scripts.

I am guessing things need to change around here

var titleAuthor= strInputLine.substr(strInputLine.indexOf(",")+1);
       titleAuthor = titleAuthor.replace(/&/g,"&");
   inputArray  = strInputLine.split(",");
   inputArray2  = titleAuthor.split(",");
   var csvFile = new File(inputArray[0]);
   var title = inputArray2[0];
   var author = inputArray2[1];
   var Country = inputArray2[2];

to add to the description field.

Thanks.

Joe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 30, 2009 Oct 30, 2009

Copy link to clipboard

Copied

It's a long time since I looked at this but think this is the code with the Description field added for you..

#target bridge 
   if( BridgeTalk.appName == "bridge" ) { 
addInfo = MenuElement.create("command", "Add CSV Information", "at the end of Thumbnail");
}
addInfo .onSelect = function () {
   TitleAuthorCountryDesc();
}

function TitleAuthorCountryDesc(){
var value = 0;
var win = new Window("palette{text:'Please wait...',bounds:[100,100,550,140]," +
               "progress:Progressbar{bounds:[20,10,430,28] , minvalue:0,value:" + value + "}" +
               "};"
         );
var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");
csv.encoding = "UTF-8";
if(csv != null){
csv.open("r");
var csvtemp=csv.read();
csvtemp =csvtemp.split("\n");
var maxcount = csvtemp.length;
csv.close();
csv.open("r");
win.progress.maxvalue =maxcount;
while(!csv.eof){ 
   win.center();
   win.show();
   win.hide();
   win.show();
   win.progress.value++; 
   strInputLine = csv.readln();
   if (strInputLine.length > 3) {
    strInputLine = strInputLine.replace(/\\/g,'/');
var titleAuthor= strInputLine.substr(strInputLine.indexOf(",")+1);
    titleAuthor = titleAuthor.replace(/&/g,"&");
   inputArray  = strInputLine.split(",");
   inputArray2  = titleAuthor.split(",");
   var csvFile = new File(inputArray[0]);
   var title = inputArray2[0];
   var author = inputArray2[1];
   var Country = inputArray2[2];
   var Description = inputArray2[3];
if(csvFile.exists){
   item = new Thumbnail(csvFile);
   md =item.synchronousMetadata; 
   var result =addTitleAuthor(md,inputArray2[0],inputArray2[1],inputArray2[2],inputArray2[3]);
   }
  }
}
}
win.close(2);
errorlog.close();
errorlog.execute();
}

function addTitleAuthor(metadata, Title, Author,Country,Description) {
var strTmpl = "TempTmpl";
var strUser = Folder.userData.absoluteURI;
var filTmpl = new File(strUser + "/Adobe/XMP/Metadata Templates/" + strTmpl + ".xmp"); 
var fResult = false;

if (filTmpl.exists) filTmpl.remove();
try{
fResult = filTmpl.open("w");
}catch(e){
  alert("Unable to create Template " +filTmpl +"\r"+e.message);
  return;
}
try{
if (fResult){
filTmpl.writeln("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"3.1.2-113\">");
filTmpl.writeln("<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">");
filTmpl.writeln("<rdf:Description rdf:about=\"\"    xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:photoshop=\"http://ns.adobe.com/photoshop/1.0/\" photoshop:Country=\""+Country +"\">");
filTmpl.writeln("<dc:title>");
filTmpl.writeln("<rdf:Alt>");
filTmpl.writeln("<rdf:li xml:lang=\"x-default\">"+Title+"</rdf:li>");
filTmpl.writeln("</rdf:Alt>");
filTmpl.writeln("</dc:title>");
filTmpl.writeln("<dc:description>");
filTmpl.writeln("<rdf:Alt>");
filTmpl.writeln("<rdf:li xml:lang='x-default'>"+Description+"</rdf:li>");
filTmpl.writeln("</rdf:Alt>");
filTmpl.writeln("</dc:description>");
filTmpl.writeln("<dc:creator>");
filTmpl.writeln("<rdf:Seq>");
filTmpl.writeln("<rdf:li>" + Author + "</rdf:li>");
filTmpl.writeln("</rdf:Seq>");
filTmpl.writeln("</dc:creator>");
filTmpl.writeln("</rdf:Description>");
filTmpl.writeln("</rdf:RDF>");
filTmpl.writeln("</x:xmpmeta>");
fResult = filTmpl.close();
metadata.applyMetadataTemplate(strTmpl, "replace");
} }
catch(e) {
alert("There was a problem with the Template");
fResult = false;
}
return fResult;
};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 30, 2009 Oct 30, 2009

Copy link to clipboard

Copied

The script works great!

Seeing the differences between the scripts helps me see how they operate.

Thanks for the quick response.

Joe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 30, 2009 Oct 30, 2009

Copy link to clipboard

Copied

The easy way to see what to change in the template section of the script is to create a new template in Bridge with the fields you require and look at the xmp file it creates.

Paul.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 30, 2009 Oct 30, 2009

Copy link to clipboard

Copied

LATEST

Good idea. I'll try it out next week.

Joe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines