Copying metadata from XMP sidecar files?

General Discussion of Scripting for Adobe Bridge

Moderators: xbytor, DavideBarranca, Paul MR

lumigraphics
Posts: 1
Joined: Tue Oct 31, 2017 7:53 pm

Copying metadata from XMP sidecar files?

Postby lumigraphics » Fri Jan 12, 2018 2:15 pm

I'm writing a replacement for the JPEG Export panel and currently getting metadata copying setup. I have it working in the testing snippet below for image formats having embedded metadata, but it doesn't copy metadata from RAW files (presumably due to the sidecar file.) Trying Adobe's Bridge CC SDK samples, SnpInspectMetadata.jsx actually throws an exception on

Code: Select all

new XMPFile()
with RAW files.

Do I need to test for sidecar files and parse those? I can't find documentation or anything online about this specific problem.

Code: Select all

this.run = JPEGExport();

function JPEGExport(){
var thumbs = app.document.getSelection("psd, jpg, png, tif, gif, CR2, nef");
if(thumbs.length != 0){
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
for(var i = 0;i < thumbs.length;i++){
if(thumbs[i].spec instanceof File){
var thumb = thumbs[i];
var selectedFile = thumb.spec;
var oldXmpFile = new XMPFile(selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);
var oldXmp = oldXmpFile.getXMP();
var bm = new BitmapData(thumbs[i].spec);
if(bm instanceof BitmapData){
var fullName = thumbs[i].name;
var finalDotPosition = fullName.lastIndexOf(".");
if(finalDotPosition > -1){
repname = fullName.substr(0 , finalDotPosition);
}
}
var exportFilePath = thumbs[i].parent.spec + "/" + repname +"_new.jpg";
var exfile = new File(exportFilePath);
bm.exportTo(exfile);
var newthumb = exfile.spec;
var myXmpFile = new XMPFile(exfile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
if (myXmpFile.canPutXMP(oldXmp)){
myXmpFile.putXMP(oldXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
}
}
}

Return to “Adobe Bridge Scripting: General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests