Skip to main content
Stephen Marsh
Community Expert
Community Expert
May 31, 2017
Question

Bridge Script to Remove Photoshop DocumentAncestors Metadata

  • May 31, 2017
  • 4 replies
  • 18853 views

Bloated files that contain “excess” Photoshop DocumentAncestors metadata have been causing a few users some grief (65mb down to 110kb)!

 

Photoshop saving issue (FILES TOO LARGE)

 

There is a script for Photoshop to remove this metadata, however as this requires an open/save it is not great for files that contain lossy compression. Bridge is the obvious place to remove this metadata. I have hacked a different script to remove this DocumentAncestor metadata.

 

I don’t understand why Bridge requires a 2 step process! All this time I thought that the code was bad, when it was “working fine”.

 

Step 1: Run the Bridge script to remove DocumentAncestors metadata (the file size does not change, when it “should”)

 

Step 2: Apply a secondary metadata change in Bridge, such as adding/removing a temporary keyword, or rotating clockwise and then rotating back counterclockwise again to “force the image to reset”

 

The second step for whatever reason will force the file to update and take into account the removal of the DocumentAncestors metadata and then applies the file size reduction!

 

The code:

 

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

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

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

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

 

 

clearDocumentAncestors = {};// create an object

 

 

clearDocumentAncestors.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/photoshop/1.0/";// set the namespace

 

 

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

 

 

  }

 

 

}

 

 

// this script only works in bridge

 

 

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

 

 

  //creage the munuItem

 

 

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

 

 

  menu.onSelect = clearDocumentAncestors.execute;

 

 

}

This topic has been closed for replies.

4 replies

Stephen Marsh
Community Expert
Community Expert
June 26, 2017
Participant
September 4, 2018

thank you!!!

is it possible to include subfolders?

Stephen Marsh
Community Expert
Community Expert
September 4, 2018

The Bridge script is working on selected files, not folders. It is beyond my current newb scripting abilities I am afraid, however I do have a work around…

Use the View menu > Show items from Subfolders command and also untick the Show folders command, then select all files and run the script.

Stephen Marsh
Community Expert
Community Expert
June 18, 2017

I have just updated my blog with with all of the known solutions to this issue:

Prepression: Metadata Bloat – photoshop:DocumentAncestors

Stephen Marsh
Community Expert
Community Expert
June 14, 2017

Forgot to link to the Photoshop script that can be setup for use with the Script Events Manager to auto run on open, save and export:

 

Inflated JPG File Size - Photoshop Document:Ancestors Metadata

SuperMerlin
Inspiring
June 1, 2017

It could be that you haven't refreshed the cache, so it doesn't show the amendments Stephen.

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

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

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

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

clearDocumentAncestors = {};// create an object 

clearDocumentAncestors.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/photoshop/1.0/";// set the namespace 

     md.DocumentAncestors = "";//delete the porperty   

  } 

//refresh cache

app.document.chooseMenuItem("PurgeCacheForSelected"); 

}; 

// this script only works in bridge 

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

  //creage the munuItem 

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

  menu.onSelect = clearDocumentAncestors.execute; 

};

Stephen Marsh
Community Expert
Community Expert
June 1, 2017

Thank you for the reply SuperMerlin!

I had tried purging the cache for the selected image/s and for the entire folder, as well as exiting and restarting Bridge. I have confirmed at the OS level that the file size does not change directly after running the script to remove the DocumentAncestors entries, however simply adding a keyword or rotation does make the file drop down in size.

That was not the answer and your updated script did not do the trick either I am afraid, however I appreciate the cleaner code than my hacked effort (as you know I can’t write scripts from scratch).

I still had to add a secondary metadata step to make the change “kick in”, which I don’t have a good answer for! I am hoping that you do have a good answer. Mac OS or Windows OS the result is the same. ExifTool does remove the metadata and reduce the file size in a single step, however it is much slower than Bridge as it has to rewrite the entire file.

If the script could add and then undo a secondary metadata step, then that would save the manual second step.

Community Expert
June 4, 2017

I just tested and it appears that once this metadata is baked into the PDF, it is no longer accessible to Bridge or ExifTool.

PDF file size with the DocumentAncestors metadata in the original JPEG AND PSD files before export to PDF = 119.5mb

PDF file size with the DocumentAncestors metadata stripped from the original JPEG AND PSD files before export to PDF = 6.5mb

Using Acrobat Pro Print Production > Preflight > Single Fixup > Remove Object Level Metadata reduces the file from 119.5mb to 5.7mb (Enfocus PitStop Pro can also do this as well).


Hi Stephen,

thank you for the tip with "Remove Object Level Metadata" from Single Fixup with Acrobat Preflight.
Don't know what version of Acrobat is supporting this fixup. I will test in Acrobat Pro 9, 10, XI and the current DC. Think, that fixup is only available with XI or DC …

Btw.: Impressive numbers with reduced file size !

Regards,
Uwe