Skip to main content
Stephen Marsh
Community Expert
Community Expert
August 10, 2017
Answered

Clear CRS Metadata

  • August 10, 2017
  • 1 reply
  • 1742 views

It appears that Bridge’s edit menu > Develop Settings > Clear do not remove Camera Raw Settings metadata that is baked into a JPEG file.

One can remove all XMP metadata, however that is a little extreme, it should be possible to target only the CRS metadata and clear it, leaving all other metadata intact (this is possible using ExifTool)…

I had a go at hacking an existing script, however it does not work. I’m sure that I’m missing something simple! Can anybody please help?

// https://forums.adobe.com/thread/290238

#target bridge // let EntendScript know what app the script is for

clearCRS.execute = function(){// create a method for that object

  var sels = app.document.selections;// store the array of selected files

  for (var i = 0; i < sels.length; i++){//loop though that array

    var md = sels.synchronousMetadata;// get the metadata for the file

     md.namespace = "http://ns.adobe.com/camera-raw-settings/1.0/";// set the namespace

     md.crs = " ";//set the porperty

  }

}

// this script only works in bridge

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

  //creage the munuItem

  var menu = MenuElement.create( "command", "Clear CRS in metadata", "at the end of Tools");

  menu.onSelect = clearCRS.execute;

}

This topic has been closed for replies.
Correct answer SuperMerlin

Here you go Stephen...

#target bridge  

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

remCRS = new MenuElement("command", "Remove Camera Raw Metadata",  "at the end of Tools");

}

remCRS.onSelect = function () {

if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var sels = app.document.selections;

for (var a in sels){

var thumb = new  Thumbnail(app.document.selections);

var md = thumb.synchronousMetadata;

var xmp = new XMPMeta(md.serialize());

        if(thumb.hasMetadata){

         XMPUtils.removeProperties(xmp, XMPConst.NS_CAMERA_RAW, "", XMPConst.REMOVE_ALL_PROPERTIES);

        var updatedPacket = xmp.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT);

        thumb.metadata = new Metadata(updatedPacket);

        }

    }

};

SuperMerlin
SuperMerlinCorrect answer
Inspiring
August 10, 2017

Here you go Stephen...

#target bridge  

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

remCRS = new MenuElement("command", "Remove Camera Raw Metadata",  "at the end of Tools");

}

remCRS.onSelect = function () {

if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var sels = app.document.selections;

for (var a in sels){

var thumb = new  Thumbnail(app.document.selections);

var md = thumb.synchronousMetadata;

var xmp = new XMPMeta(md.serialize());

        if(thumb.hasMetadata){

         XMPUtils.removeProperties(xmp, XMPConst.NS_CAMERA_RAW, "", XMPConst.REMOVE_ALL_PROPERTIES);

        var updatedPacket = xmp.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT);

        thumb.metadata = new Metadata(updatedPacket);

        }

    }

};

Stephen Marsh
Community Expert
Community Expert
August 10, 2017

Thank you SuperMerlin!

I was thinking that perhaps line 18 in the hacked script was incorrect, however as you re-wrote the entire code I now suspect that I was way out of my depth!

For future reference, the ExifTool code to remove Camera Raw Settings metadata is:

Mac OS:

exiftool -r -XMP-crs:all= 'os-path/to/file/or folder'

Win OS:

exiftool -r -XMP-crs:all= "os-path\to\file\or folder"