I'm writing a replacement JPEG export panel for Bridge, and currently working on copying metadata. I have it working for any source format with embedded metadata using the testing code stub below. But this doesn't work with RAW files, presumably due to using XMP sidecars. Note that the "SnpInspectMetadata.jsx" sample included in the Bridge CC SDK also fails, in fact it throws an exception when trying to run new XMPFile(). So how do I get metadata from RAW files? Do I have to test for sidecars? Looking at one with a text editor, there are lots of extra fields. My script works otherwise to export JPEG files, and copies metadata from image formats other than RAW. 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.spec instanceof File){ var thumb = thumbs; 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.spec); if(bm instanceof BitmapData){ var fullName = thumbs.name; var finalDotPosition = fullName.lastIndexOf("."); if(finalDotPosition > -1){ repname = fullName.substr(0 , finalDotPosition); } } var exportFilePath = thumbs.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); } } } } }
... View more