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

Copying metadata from XMP sidecars?

LEGEND ,
Jan 12, 2018 Jan 12, 2018

Copy link to clipboard

Copied

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);

                                    }                             

                                }

                    }

                }

            }

TOPICS
Scripting

Views

1.4K

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

correct answers 1 Correct answer

LEGEND , Jan 12, 2018 Jan 12, 2018

Ah nevermind. Had to use the Thumbnail object, not thumbnail.spec

var xmp = new XMPMeta(thumb.synchronousMetadata.serialize());

Votes

Translate

Translate
Guide ,
Jan 12, 2018 Jan 12, 2018

Copy link to clipboard

Copied

var xmp = new XMPMeta(selectedFile.synchronousMetadata.serialize());

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
LEGEND ,
Jan 12, 2018 Jan 12, 2018

Copy link to clipboard

Copied

Doesn't work. It throws an error of "undefined is not an object" with both RAW and JPEG source files. And the Object Model Viewer says that Thumbnail.synchronousMetadata returns undefined if the node doesn't support embedded metadata.

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
LEGEND ,
Jan 12, 2018 Jan 12, 2018

Copy link to clipboard

Copied

Ah nevermind. Had to use the Thumbnail object, not thumbnail.spec

var xmp = new XMPMeta(thumb.synchronousMetadata.serialize());

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 Expert ,
Jan 14, 2018 Jan 14, 2018

Copy link to clipboard

Copied

While on the topic, I thought that this may be helpful (or at least interesting):

Bridge Export Panel Sample Code | Photoshop Family Customer Community

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
LEGEND ,
Jan 14, 2018 Jan 14, 2018

Copy link to clipboard

Copied

LATEST

Yes I posted that script. I’m maybe halfway done writing a new JPEG export panel.

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