brad_varey's profile

2 Messages

 • 

100 Points

Wed, Aug 3, 2011 4:22 PM

Photoshop: Saving Photoshop Script Document Properties

I am writing a VB app that opens a RAW file under Photoshop scripting, updates the document's Info.Title and Info.Caption properties, then saves.

doc.Save doesn't seem to work, as this attempts a PSD save. I have tried various SaveAs options, but all these seem to want to save a copy. I want to update just these two properties on the original document.

Any help out there, anyone?

Thanks in advance.

Brad

Responses

361 Messages

 • 

6.9K Points

10 y ago

Raw files are read only! You can update the metadata in the xmp sidecar using javaScript via Photoshop or Bridge.

15.1K Messages

 • 

195.8K Points

10 y ago

If you changed something in the document that won't work in the current (opened) file format, then Photoshop defaults to saving PSD.

And, as Paul pointed out, Camera RAW files cannot be saved, so saving them must default to PSD.

361 Messages

 • 

6.9K Points

10 y ago

You might me able to pass the javaScript by the "DoJavaScript" command?
Here is one way of updating the metadata without open the Camera Raw file.


#target photoshop
var xmpFile = new File( "/c/folderName/folderName/fileName.xmp" );

var Title = "This is the best Photo ever";
var Caption = "This is also known as the description field";
setMetadata( xmpFile, Title, Caption );

function setMetadata( file, Title, Caption ){
try{
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
if(file.exists){
file.open('r');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.open("r", "TEXT", "????");
var xmpStr = file.read();
file.close();
}else{
var xmpStr='';
}
var xmp = new XMPMeta( xmpStr );
if(Title != ''){
xmp.deleteProperty(XMPConst.NS_DC, "title");
xmp.appendArrayItem(XMPConst.NS_DC, "title", Title, 0, XMPConst.ALIAS_TO_ALT_TEXT);
xmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
}
if(Caption != ''){
xmp.deleteProperty(XMPConst.NS_DC, "description");
xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Caption );
}
file.open('w');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.write( xmp.serialize() );
file.close();
}catch(e){alert(e+"-"+e.line);}
};