Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
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;
};
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks Stephen, I've had problems with the cache before not getting updated. I will have a play later on and see if it can be fixed.
Copy link to clipboard
Copied
The code seems to work okay for me without doing any other changes, I have been using this jpg to do the testing.
Copy link to clipboard
Copied
Thanks SuperMerlin, the strange thing is that the script does not reduce the file size that JPEG, when it does on the bloated PSD file that I have been testing! ExifTool does reduce the size of the data on that JPEG (3.7mb to 434kb)…
I have uploaded the 67mb PSD file (posted in one of the numerous forum topics on this subject) here:
Copy link to clipboard
Copied
OK, that appears to work on Windows but not on the Mac with the Bad.jpg
I have narrowed it down to the script not working correctly in Bridge CS6, however it does work correctly in Bridge CC2017 on both Mac and Windows!
Copy link to clipboard
Copied
Just so that I understand:
Copy/paste the code into a .txt file and save the file
Change the extension to .jsx and drop it in the Bridge CC Scripts folder
It should show up under the Bridge CC Tools menu.
Does that sound right? Haven't tried this in a while.
Gene
Copy link to clipboard
Copied
Yes, the simplest way to the startup scripts folder is to use Bridge’s Preferences menu > Startup Scripts > Reveal My Startup Scripts button.
Quit and restart Bridge and you will then be asked to enable the newly installed startup script.
Make sure that a file is selected before using the Tools menu! :]
If you can’t find the script listed in the Tools menu, ensure that it is actually enabled:
Copy link to clipboard
Copied
Thanks Stephen,
The script works instantly on the bad jpeg but I had to use the rotate view trick for the psd results to show. Cmd ] then Cmd z
I think it's rare that I get this problem, but now I have a good answer and Bridge does remove the metadata without rewriting the file.
A quick and easy "nondestructive" approach.
Gene
OSX 10.12.5/Bridge CC 2017
Copy link to clipboard
Copied
That is strange Stephen, could you test this script as it does the rotation to see if this works.
// 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 = "";
}
app.document.chooseMenuItem("Rotate90CW");
app.document.chooseMenuItem("Rotate90CCW");
};
//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;
};
Copy link to clipboard
Copied
That works, the rotation steps force the file size change to kick in!
Copy link to clipboard
Copied
Great ! I still wonder why it doesn't work without it?
I also noticed that even rotating an untouched file reduced the file size by one or two k.
Copy link to clipboard
Copied
It still does not work with the bad.jpg in CS6, however the PSD does work. CC2017 is all good for both. Strange indeed.
Copy link to clipboard
Copied
I get this error when I try to load SuperMerlin's revised script in CC 2017
Any idea what that is?
Copy link to clipboard
Copied
That line is ok and does work in Bridge 2017, the only reason I can think of is you text editor that you are using might be adding control characters into the script.
Copy link to clipboard
Copied
Thanks SuperMerlin, I'll try a different editor and report back. I thought it was a Mac glitch.
Gene
Copy link to clipboard
Copied
Hi all,
very interesting topic!
I wonder if Bridge can remove metadata in exported PDFs from InDesign that also showing this bloated file sizes, because the bloated JPGs, PSDs or whatnot are placed on a page and the exported PDFs will contain also the metadata, because you can handle placed images (also placed PDFs or InDesign pages) as "pass-through-data" if you do not touch them by resampling or cropping while export.
And would Bridge leave all other properties of the PDF untouched?
I've seen the issue with bloated files also mentioned in the InDesign forums.
Advice was: Remove metadata from exported pages:
1. Open the PDF with Acrobat Pro and remove metadata there.
2. Or: Do not use InDesign's export functionality. Instead do: (1) Print to PostScript , (2) Distill to PDF.
Both solutions are working. But it's a all-or-nothing one.
With a Bridge script I was hoping to do it selectively with a specific namespace and attribute.
// EDITS HERE:
Regarding gener7 and the ExtendScript error:
Would the menu title string always be in English even if you are running the script with a localized non-English version of Bridge? Maybe that's the problem?
Guess no since your error message is in English.
Hm. I should test the script with my German version(s) of Bridge…
Regards,
Uwe
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
I found it in DC2017, not sure when it was originally introduced (I still stubbornly use version X as I can’t stand or use the dumbed down interface of the later versions).
Copy link to clipboard
Copied
gener7 wrote
Thanks SuperMerlin, I'll try a different editor and report back. I thought it was a Mac glitch.
Gene
Tried a different browser (Safari) to copy/paste the code into TextWrangler instead of TextEdit, still getting errors when loading the script on startup.
ExtendScript shows this line in red. "Result: Undefined"
Copy link to clipboard
Copied
Yes it will, you have not set the target as Bridge, you have it set for ExtendScript Toolkit, change it to Bridge (Top left dropdown) and you should be good.
Copy link to clipboard
Copied
Still no good. Any attempt to load the script as a Startup in Bridge gives me this error.
"New Script`' is the name I gave to the textfile to differ it from the earlier script.
gives me the error and clears the checkbox.
Copy link to clipboard
Copied
From the previous picture you were trying to LOAD the script into Bridge.
You must first delete the script that allready exists, as this is the one that has the faults in it!
Then you can load the script from ExtendScript Toolkit then test it in Bridge.