• 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 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

David,

I have a script that can do that; but, it will require modification.

Drop me a line: bob.stucky@starband.net

Bob

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 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

EDIT: Bob beat me to it.

This might do.
It uses a csv file, three fields comma seperated.
FileName including path eg: c:/folder/picture.jpg
Title and Author details.
It updates the Title and Autor fields in IPTC.
To install unzip and place this script into the following folder:
Start Bridge
Edit - Preferences -Startup Scripts
At the bottom click the "Reveal Button" this will open the folder where the script should be placed.
To use:
Mouse Right click (menu) and select "Update Entry Details"



#target bridge

if( BridgeTalk.appName == "bridge" ) {

addInfo = new MenuElement("command", "Update Entry Details", "at the end of Thumbnail");

}

addInfo .onSelect = function () {

main();

}

function main(){

var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");

if(csv != null){

csv.open("r");

while(!csv.eof){

strInputLine = csv.readln();

if (strInputLine.length > 3) { // Make sure it isn't a blank line

strInputLine = strInputLine.replace(/\\/g,'/'); //Change backslash to forward slash.

inputArray = strInputLine.split(",");

var csvFile = new File(inputArray[0]);

var title = inputArray[1];

var author = inputArray[2];

if(csvFile.exists){ //Check if file exists

writeMetadata(inputArray[0],inputArray[1],inputArray[2]);

}

}

}

}

}



function writeMetadata(file,title,author){

item = new Thumbnail(file);

md =item.synchronousMetadata;

md.namespace = "http://purl.org/dc/elements/1.1/"

md.title = title;

md.namespace = "http://ns.adobe.com/photoshop/1.0/";

md.Author = author;

}

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
New Here ,
Oct 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

Paul,
Thanks a bundle for your script. Bob has also very kindly agreed to send me his one when he has had a chance to check it over (he hasn't used it for some time). It will be interesting to see how the scripts compare.

I'll post back here in due course with my comments on how I get on.

David

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
New Here ,
Oct 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

Paul,
I've tried your script with a fairly short test csv file. It runs through all the files one by one, but in each case I get the message "There was an error writing metadata to xxxxxx". What do you think might be going wrong?

BTW, I don't have any problem writing metadata to these image files manually with Bridge.

David

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 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

Just tried it again with 20 files and all were updated.
My csv format is like this:-
C:/Pictures/China/Paul/P1000662.jpg,Title,Author Details
C:/Pictures/China/Paul/P1000663.jpg,Title Details,More Author Details

Etc..

I have even tried with backslashes in the file path and that works as well.
I will keep looking to see if I can find something.

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
New Here ,
Oct 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

Could the problem be caused by my having embedded blanks in my filenames?

My CSV file includes rows like the following:

C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\WebSites\SIEWebsite\EntryImages\E2-1261 Moray & Max.jpg,Moray & Max,David Anderson

C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\WebSites\SIEWebsite\EntryImages\E3-1261 Early morning in Bruges.jpg,Early morning in Bruges,David Anderson

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 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

Mmm I don't this the spaces will cause a problem.
Could you try just one line with the slash the other way and see if that works?

C:/Documents and Settings/Administrator/My Documents/Visual Studio 2008/WebSites/SIEWebsite/EntryImages/E2-1261 Moray & Max.jpg,Moray & Max,David Anderson

I'm trying to create another version using AdobeXMPScript, this is proberbly what Bobs will be using? He is "The Bridge Man"

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 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

Here is the other version, again this works on my system.
You will have to remove the last script or overwrite it with this one to test.



#target bridge

if( BridgeTalk.appName == "bridge" ) {

addInfo = new MenuElement("command", "Update Entry Details", "at the end of Thumbnail");

}

addInfo .onSelect = function () {

main();

}

function main(){

var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");

if(csv != null){

loadXMPScript();

csv.open("r");

while(!csv.eof){

strInputLine = csv.readln();

if (strInputLine.length > 3) {

strInputLine = strInputLine.replace(/\\/g,'/');

inputArray = strInputLine.split(",");

var csvFile = new File(inputArray[0]);

var title = inputArray[1];

var author = inputArray[2];

if(csvFile.exists){

var file = new Thumbnail(csvFile);

var xmpFile = new XMPFile(file.path, XMPConst.UNKNOWN,XMPConst.OPEN_FOR_UPDATE);

var xmp = xmpFile.getXMP();

xmp.deleteProperty(XMPConst.NS_DC, "creator");

xmp.deleteProperty(XMPConst.NS_DC, "title");

xmp.appendArrayItem(XMPConst.NS_DC, "creator", author, 0,XMPConst.ARRAY_IS_ORDERED);

xmp.appendArrayItem(XMPConst.NS_DC, "title", title, 0,XMPConst.ARRAY_IS_ORDERED);

if (xmpFile.canPutXMP(xmp)) {

xmpFile.putXMP(xmp);

}

xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

}}}

}

}

unloadXMPScript();



function loadXMPScript()

{

var results = new XMPLibMsg("XMPScript Library already loaded", 0, false);



if (!ExternalObject.AdobeXMPScript)

{

try

{

ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

results.message = "XMPScript Library loaded";

}

catch (e)

{

results.message = "ERROR Loading AdobeXMPScript: " + e;

results.line = e.line;

results.error = true;

}

}



return results;

}

function unloadXMPScript()

{

var results = new XMPLibMsg("XMPScript Library not loaded", 0, false);



if( ExternalObject.AdobeXMPScript )

{

try

{

ExternalObject.AdobeXMPScript.unload();

ExternalObject.AdobeXMPScript = undefined;

results.message = "XMPScript Library successfully unloaded";

}

catch (e)

{

results.message = "ERROR unloading AdobeXMPScript: " + e;

results.line = e.line;

results.error = true;

}

}



return results;

}

function XMPLibMsg (inMessage, inLine, inError)

{

this.message = inMessage;

this.line = inLine;

this.error = inError;

}

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
New Here ,
Oct 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

The new version runs without any error or user feedback of any kind. However, none of my 4 test images have had their IPTC Creator or Title metadata fields updated.

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 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

I am wondering if it isn't finding the file?
This will put up an alert if it can not find the document.



#target bridge

if( BridgeTalk.appName == "bridge" ) {

addInfo = new MenuElement("command", "Update Entry Details", "at the end of Thumbnail");

}

addInfo .onSelect = function () {

main();

}

function main(){

var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");

if(csv != null){

loadXMPScript();

csv.open("r");

while(!csv.eof){

strInputLine = csv.readln();

if (strInputLine.length > 3) {

strInputLine = strInputLine.replace(/\\/g,'/');

inputArray = strInputLine.split(",");

var csvFile = new File(inputArray[0]);

var title = inputArray[1];

var author = inputArray[2];

/////////////////////////////////////////////////////////////////////////////////////////////////

if(!csvFile.exists) alert(csvFile + " Does not exist"); //////////Check if file exists

//////////////////////////////////////////////////////////////////////////////////////////////////

if(csvFile.exists){

var file = new Thumbnail(csvFile);

var xmpFile = new XMPFile(file.path, XMPConst.UNKNOWN,XMPConst.OPEN_FOR_UPDATE);

var xmp = xmpFile.getXMP();

xmp.deleteProperty(XMPConst.NS_DC, "creator");

xmp.deleteProperty(XMPConst.NS_DC, "title");

xmp.appendArrayItem(XMPConst.NS_DC, "creator", author, 0,XMPConst.ARRAY_IS_ORDERED);

xmp.appendArrayItem(XMPConst.NS_DC, "title", title, 0,XMPConst.ARRAY_IS_ORDERED);

if (xmpFile.canPutXMP(xmp)) {

xmpFile.putXMP(xmp);

}

xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

}

}

}

}

}

unloadXMPScript();



function loadXMPScript()

{

var results = new XMPLibMsg("XMPScript Library already loaded", 0, false);



if (!ExternalObject.AdobeXMPScript)

{

try

{

ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

results.message = "XMPScript Library loaded";

}

catch (e)

{

results.message = "ERROR Loading AdobeXMPScript: " + e;

results.line = e.line;

results.error = true;

}

}



return results;

}

function unloadXMPScript()

{

var results = new XMPLibMsg("XMPScript Library not loaded", 0, false);



if( ExternalObject.AdobeXMPScript )

{

try

{

ExternalObject.AdobeXMPScript.unload();

ExternalObject.AdobeXMPScript = undefined;

results.message = "XMPScript Library successfully unloaded";

}

catch (e)

{

results.message = "ERROR unloading AdobeXMPScript: " + e;

results.line = e.line;

results.error = true;

}

}



return results;

}

function XMPLibMsg (inMessage, inLine, inError)

{

this.message = inMessage;

this.line = inLine;

this.error = inError;

}

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
New Here ,
Oct 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

I've just tried your latest version of the script but, once again, it runs without any user feedback or file metadata updates. Do I need anything other than Bridge CS3 to run these scripts?

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 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

No I am using Bridge CS3, Windows Vista. I think we need Bobs script now David.

It's strange that both scripts work on my machine but not on yours.

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
New Here ,
Oct 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

I'm using Win XP Pro but I doubt if that's relevant.

Anyway, thanks for all the help so far. It's much appreciated. It may well turn out that I'm doing something stupid. I will have another look tomorrow morning with a fresh brain.

David

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
Explorer ,
Oct 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

There is always ExifTool (http://www.sno.phy.queensu.ca/~phil/exiftool/).
It's a command-line program that will take text (and images) as input and modify
the images accordingly. I use it in cases where I need to update a massive
number of images in a single pass.

-X

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 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

Hello all,

I was looking for the same/similar script.
A way to batch import description, title, description writer into metadata of jpg and tiff files through Bridge CS3 on a MAC using a csv file.

When I came over to your post I thought "heaven"
So I copied your code and in order to avoid compatibility problems I placed my csv file inside the folder.
Unfortunately it returns NO DATA

If you get to solve this puzzle could you please post it here?

Thanx in advance
Michael

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
New Here ,
Oct 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

Hi xbytor,
Thanks for the suggestion. As it happens, someone else on another forum (http://thedambook.com/smf/index.php?topic=3672.0) also suggested using ExifTool and I am in the middle of experimenting with ways to invoke it from ASP.NET. This might prove to be a very useful method, though I would still like to find a way to make Bridge scripting do the job.

David

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 31, 2008 Oct 31, 2008

Copy link to clipboard

Copied

Hi xbytor
I know, downloaded and tried to use the ExifTool on the Mac.
Unfortunately I am not very good with the command lines.

Michael

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
New Here ,
Nov 03, 2008 Nov 03, 2008

Copy link to clipboard

Copied

I am able to invoke ExifTool from ASP.NET, but only in a local test environment. Doing this on my live website would require a higher level of security access than ISPs are willing to give for a shared hosting environment. I've no doubt that I could use ExifTool for running a batch update (though I've not yet tried doing that) but I am still very much interested in finding a way to make Bridge scripting work for me.

Paul,
Somebody emailed me privately to say that they had also had problems in getting your scripts to work. Since they work on your PC, is there perhaps a dependency on some other software component?

David

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 ,
Nov 03, 2008 Nov 03, 2008

Copy link to clipboard

Copied

I have just tested the script on my other PC XP Pro and it works on that, now I have tried it on a G5 Mac and it didn't work! so I will have a look at that machine tonight (I do not know my way araound a Mac so it will be a challenge!).

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
Explorer ,
Nov 03, 2008 Nov 03, 2008

Copy link to clipboard

Copied

Paul_R@adobeforums.com wrote:
> I have just tested the script on my other PC XP Pro and it works on that, now I have tried it on a G5 Mac and it didn't work! so I will have a look at that machine tonight (I do not know my way araound a Mac so it will be a challenge!).

I just tried this on BridgeCS4 on my Mac. It worked fine. One thing that you
might want to change is to place the call to unloadXMPScript(); at the end the
same block as the call to loadXMPScript(). And put a try/catch block around
everything in between.

-X

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 ,
Nov 03, 2008 Nov 03, 2008

Copy link to clipboard

Copied

Thanks X, I just realised it was my fault it didn't work on the Mac! I was using an external USB drive formated as NTFS and I believe Macs and NTFS do not go together well. As soon as I moved the files to Fat32 it all worked again.

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
Explorer ,
Nov 03, 2008 Nov 03, 2008

Copy link to clipboard

Copied

Paul_R@adobeforums.com wrote:
> I was using an external USB drive formated as NTFS and I believe Macs and NTFS do not go together well.

google for "ntfs-3g mac os x". It's what I use and it seems to be pretty stable.

-X

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 ,
Nov 03, 2008 Nov 03, 2008

Copy link to clipboard

Copied

Many thanks again X, I will certainly give it a try.

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 ,
Nov 03, 2008 Nov 03, 2008

Copy link to clipboard

Copied

Hi all,

Could someone please email me the script (photomadesATgmailDOTcom) or if you could just repost the complete one here at the forum? I try copying and pasting from Paul R, "Can I automate the writing of XMP metadata into JPEG and TIFF files?" #10, 31 Oct 2008 2:17... but I cannot get it to work. I must be missing something.

Thank you
Michael

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