Skip to main content
wckdtall
Inspiring
February 3, 2016
Answered

Inflated JPG File Size - Photoshop Document:Ancestors Metadata

  • February 3, 2016
  • 12 replies
  • 74255 views

Has anyone run into this issue?

I have a JPG that I have removed all image from, and filled with white. When I save it, the size is 7.89 MB. If I go into Bridge and clear the metadata, most likely the "<Document:Ancestors>" which contains "<rdf:bag>" , and 100+ lines of Hexadecimal code, the file size goes down to around 150KB. Maybe I'm missing a file save option out of photoshop, but It seems this metadata should be scrubbed on file saved. Additionally, does anyone know what kind of information is stored in Document Ancestors? Or if there is image information embedded that could potentially be extracted?

This topic has been closed for replies.
Correct answer wckdtall

I was able to reach out to Adobe through my work. They mentioned it was an abnormal behavior for there to be over 100,000 lines of Document Ancestors, and thought it may be because it was a template. It turns out a lot of the art I work with has extensive lines of Ancestors, and when placing them into a completely new file, that file acquires them. A lot of these assets are CG renders, which too I would believe to be new files. While I'm not sure where the Document Ancestors originated, I was able to figure out how to eliminate them:

function deleteDocumentAncestorsMetadata() {

    whatApp = String(app.name);//String version of the app name

    if(whatApp.search("Photoshop") > 0)  { //Check for photoshop specifically, or this will cause errors

        //Function Scrubs Document Ancestors from Files

        if(!documents.length) {

        alert("There are no open documents. Please open a file to run this script.")

        return;

        }

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

        var xmp = new XMPMeta( activeDocument.xmpMetadata.rawData);

        // Begone foul Document Ancestors!

            xmp.deleteProperty(XMPConst.NS_PHOTOSHOP, "DocumentAncestors");

            app.activeDocument.xmpMetadata.rawData = xmp.serialize();

         }

}

//Now run the function to remove the document ancestors

deleteDocumentAncestorsMetadata();

Adobe mentioned that these were meant for file forensics and did not contain any sensitive information. I also tested scripting this with a loop provided in one of the Javascript Reference Documents, and while it does successfully eliminate the ancestors without opening the file, it doesn't reduce the file size until it is opened, and saved again. So, it must be run before save on an open file and will incorporate easily into my save scripts. Problem solved!

If you are new to scripting, copy the above lines into a plain text document(no formatting as it may not work) and change the extension to JSX. From there in Photoshop go to File>Scripts>Browse, and locate this script to run it on an open file. This can be tedious to do per file, so if you have to run on many, place the file in a stationary location, and record an action that runs this script. If you are unfamiliar, once the script is recorded you can batch this script on files by navigating File > Automate > Batch. As the file does need to be saved to eradicate the document ancestors, I recommend pairing your script action with a save as in a stationary location, as save as actions will remember the folder you saved to.

12 replies

Participant
February 12, 2021

thank you SO MUCH.

li-jent93610173
Participant
October 16, 2020

OMG!!!
You're a life saver T-T

THX!!!!!!!!

giahai
Participant
June 13, 2020

Hello, i think i run into similar issue.

My file is originally 300MB, but it just includes 3 very tiny artboards for web banner which within 300x350px. Every artboard has only 1 layer with no special effect. Items in the artboards are copied and pasteed from another file. I suspect something wrong so i delete all the layers and remain 1 empty layer in one artboard. the file is still at 280MB??!?!

I tried your method but there is an error while running the jsx file

i am not sure which part went wrong...

Stephen Marsh
Community Expert
Community Expert
February 12, 2021

You incorrectly saved the file as a RTF rich text file, not as plain text file.

wckdtall
wckdtallAuthor
Inspiring
October 18, 2017

elmimmo​ could you clarify a bit? You mention that dramatic file size loss was not achieved for

  • Solution #1: Adobe Photoshop Script (v. 17.0.0 a.k.a 2015.5)

However, you go on to later say that exif tool left you with thousands of blank lines, and cited it as a success. As PNGs use a lossless compression you may not notice too much of a difference in file size w/ and w/out Doc Ancestors using maximum compression. PNGs can be tricky, I've worked with some recently that using fast save are 400MB, and using max compression and save are 2.8 MB. No loss on the image quality or information but compression made a world of difference.

Stephen Marsh
Community Expert
Community Expert
October 18, 2017

iamwickedtall1 – I would suggest that you read posts #24 and #25 again. The Photoshop and Bridge Scripts when used on PNG files that contain photoshop:DocumentAncestors metadata do not correctly remove the metadata and leave blank lines. I confirmed this behaviour in post #25 and also confirmed that ExifTool does correctly remove this metadata from PNG files and that it can also fix/clean the blank lines left when these scripts are run on PNG files.

wckdtall
wckdtallAuthor
Inspiring
October 18, 2017

Reread both, and I'm still seeing that Script Solution #1, works just fine, and have been using with no problem through photoshop. Only difference between my workflow and what you've been using is exifTool, which maybe potentially there are special characters not being handled on that end? In looking between the tags elmimmo mentioned, the only difference I have is an end = "w" for xpacket. In both the raw XMP with doc ancestors, and the cleansed version, there are only about 20 lines in between the 2, although in my document there are also 2047 spaces on those lines. I use this script for tif, psd, jpg and tif and have run into no issues with inflating the file again. I wonder if exifTool is otherwise delimiting the file by spaces at that point and reading them to their own line. I exported my XMP via bridge and didn't see an issue even in text editor, can you confirm that you're seeing the same within a simple save as from Photoshop after running the script?

Known Participant
October 16, 2017

In my test with a PNG file, from the methods listed in iamwickedtall1​'s blog post “Prepression: Metadata Bloat – photoshop:DocumentAncestors​”, the ones that accomplished dramatic lossless file size reduction were:

  • Solution #3: ExifTool
  • Solution #4: PDF Files & Acrobat DC Pro (v. 17.012.20098)

but the following did not:

  • Solution #1: Adobe Photoshop Script (v. 17.0.0 a.k.a 2015.5)
  • Solution #2: Adobe Bridge Script (v. 6.2.0.179)
  • Addendum – Solution #5: Adobe Photoshop Script (v. 17.0.0 a.k.a 2015.5)

In case of the latter three, the scripts run apparently successfully, but the PNG weighted approximately the same. Furthermore, subsequently trying Solution #3: Exiftool with the PNG did nothing too. In order to diagnose why, I extracted the XMP metadata from the processed PNG using exiftool:

exiftool -b -XMP image.png >out.xmp

Opening it in a text editor revealed that, while all Document:Ancestors entries were gone, now there were thousands of lines filled only with spaces acting as padding between </x:xmpmeta> and <!--?xpacket end="r"?-->, which explains why exiftool could not fix the image after it has unsuccessfully been processed by the solutions that did not work.

Note that while Bridge does not allow rotating a PNG, I tried adding an IPTC keyword to force Bridge into updating the file or whatever. The keyword was inserted, but the lines filled with spaces in the XMP metadata block remained.

Stephen Marsh
Community Expert
Community Expert
October 17, 2017

elmimmo a small correction, the blog is mine – not iamwickedtall1’s.

Thank you for your tests and posting the findings. I did not try PNG, I remember PSD and JPEG not having any issues, not sure about TIFF. I have added a note to the blogpost.

I have a feeling that the 3 scripts that did not work as expected were not intended for PNG or that PNG requires special handling.

I can confirm you results.

When I ran the script on a PNG file and looked at the XMP dump, there were 41,453 lines of data, many blank.

I then ran the following ExifTool command to rebuild the metadata:

exiftool -v -all= -tagsfromfile @ -all:all -unsafe -icc_profile PATH-TO-FILE

Which fixed the file and resulted in 150 lines of data and a reduction in file size.

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

seanh86913514
Participant
June 13, 2017

I too have this problem. I find it amazing that there isn't an easy solution to this issue within Photoshop. I'm trying to export simple JPEGs and they are coming out at way over 100mb!

Re the text for using in the script, should it be pasted into Text Edit (on a Mac) and then saved with the extension .jsx?

gener7
Community Expert
Community Expert
June 13, 2017

Correct and for best results place it in the Startup Scripts folder of Bridge. That way it loads up as a menu item under Tools.

You can select one or many files, run the command and it removes the ancestor metadata without the need to resave the files.

Stephen Marsh
Community Expert
Community Expert
June 13, 2017

Hi gener7, I believe that the script is a Photoshop script, not Bridge. This Photoshop script can be setup to automatically run when files are opened, saved or exported using the Scripting Events Manager, as described in my post here:

Re: Photoshop saving issue (FILES TOO LARGE)

The Bridge script that you are thinking of is in this thread:

Bridge Script to Remove Photoshop DocumentAncestors Metadata

Cheers!

Participant
April 21, 2017

I have another way to figure out this,just select the layers all you want,then click right of your mouse,choose copy layers,then select NEW at the bottom of the options,then save this new document.you will find this one is more smaller than the original file.

Stephen Marsh
Community Expert
Community Expert
April 6, 2016

I too would be interested in looking at a smaller sized sample file bloated with this unwanted metadata. It *should* be easy enough to remove using ExifTool.

Stephen Marsh
Community Expert
Community Expert
April 21, 2017

It is easy to remove only this metadata using ExifTool:

 

Photoshop files much larger than usual.

Participant
March 16, 2016

Is there any way to do this on Photoshop files without the use of scripts? I am not a programmer or coder. Save for Web does the trick for a single save of a layer but what about a Photoshop file with layers, smart objects or one that is bigger than 8K? Very frustrating this problem.

wckdtall
wckdtallAuthor
Inspiring
March 17, 2016

You can open the XMP in Bridge and apply a template that is without the doc ancestors but this is really the only other way. If you're working mostly on photoshop files, the inflation is negligible, and you hardly notice it on a 100MB+ file. But if you are like me and are exporting jpgs to email, it is a huge pain. The script is incredibly simple to use if you want me to post it, that mixed with an action, and it's super easy to use. Surprisingly only 11 lines of code to eradicate an annoying issue.

Participant
March 17, 2016

Thanks for replying so quickly. Yes, I tried with Bridge that exact same thing and it worked on some files but today I Can't get it to work... the templates are grayed out when I try to apply them. When I import them into Photoshop inside File info and select Clear it does wipe and replace but as soon as I close the file info it's back. Ugh! And yes, I cannot run layers to files anymore with this in the Photoshop file, every JPEG it outputs is 30MB or more and only Save-For-Web which is very limiting. What a royal pain in the a**. I would love to try your script and yes if you could explain how to apply/run it -- much appreciated -- I've been dealing with this issue for many months now and at my wits' end.