Skip to main content
wckdtall
Inspiring
February 3, 2016
解決済み

Inflated JPG File Size - Photoshop Document:Ancestors Metadata

  • February 3, 2016
  • 返信数 12.
  • 74255 ビュー

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?

このトピックへの返信は締め切られました。
解決に役立った回答 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

wckdtall
wckdtall作成者解決!
Inspiring
February 18, 2016

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.

Participant
September 1, 2017

This saved me. So helpful. We had 100kb files that refused to save at anything less than 8MB because of all the document ancestor data that had built up over the years. 

At my company, people will just open last month's PSD file (as a template) then replace the contents under the template... save a new filename... delete the layer and move on.  Over years of this, the data built up to a point we couldn't get anything to come out at the right size without doing Save For Web (legacy) on every single file, when a simple Save-As-JPG action/batch would be much easier.

Thank you so much.

wckdtall
wckdtall作成者
Inspiring
September 2, 2017

Glad this thread helps! Also to note, each PS smart object retains its own document ancestors, which if using a lot can significantly increase a working file's size. Similarly, InDesign retains info like document ancestors that can be expunged with a simple save as:

How to reduce the InDesign file size?

Just thought it worth the mention as I recently ran into a 5 GB indd file that was reduced significantly by this method. Adobe stores way too much information hidden in metadata that the every day user isn't privy to.

gener7
Community Expert
Community Expert
February 3, 2016

According to the XMP specifications (search Google for "XMP Specifications Part" -- there are three parts), the Document Ancestors denote "copy-and-paste or place" operations. These do not identify what was incorporated into the file -- it could be an entire picture or a portion of a picture. We only know that these four separate files were incorporated into an existing file. These records identify other documents (DID) that were added to this document. This is explicitly the definition of a composition: a picture made from other pictures.

Gene

wckdtall
wckdtall作成者
Inspiring
February 3, 2016

Thanks for this! Unfortunately, save for web isn't an option since these JPGs are for print or reference, and I generally have to email multiple to coworkers. Save for web also tanks when an image is too big. I cleared this info directly from a photoshop file, and resaved it finding that it immediately added it back.

I will definitely look that up, and hope to get a better understanding of why it's inflating my files so much. Potentially I may have to figure out how to scrub the file on save with a script.

gener7
Community Expert
Community Expert
February 3, 2016

That's why I removed SFW in my reply. It shouldn't be hard to remove what you don't want and keep important information like Print size.

Also if Photoshop Preferences > History Log is active, you can decide to disable that or direct the History to a text file if you want clients to have a history of your work for billing purposes.

Gene