35 Replies Latest reply on Oct 23, 2017 1:11 PM by Stephen_A_Marsh

    Inflated JPG File Size  - Photoshop Document:Ancestors Metadata

    iamwickedtall1 Level 1

      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?

        • 1. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
          gener7 Adobe Community Professional & MVP

          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

          • 2. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
            iamwickedtall1 Level 1

            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.

            • 3. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
              gener7 Adobe Community Professional & MVP

              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

              • 4. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                iamwickedtall1 Level 1

                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.

                1 person found this helpful
                • 5. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                  raytrazer Level 1

                  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.

                  • 6. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                    iamwickedtall1 Level 1

                    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.

                    • 7. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                      raytrazer Level 1

                      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.

                      • 8. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                        iamwickedtall1 Level 1

                        Sure thing. Think I ran into the same thing in Photoshop even when saving out, it miraculously came back. The trick with the script is that it does have to save the file or a new file in order to work. The file holds on to disk space if the script is run without opening the file, but my script will be reliant on saving, because of my previous statement.

                         

                        When I was emailing with adobe support, they too recommended save for web, and quickly withdrew that recommendation when I brought up the same, it does not work well for anything over web size.

                         

                        If you want to send me a file to test, shoot me a message with a dropbox, wetransfer link or email address, I can test it and make sure it works for your issue. You can even fill the image with a solid color(if you'd prefer not to share a full image) and if it is truly a metadata issue, it will still be inflated.

                        • 9. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                          raytrazer Level 1

                          That's very generous of you. The file I have is quite big, i.e. 4GB. Would you mind running it? If so send me your email to michael@raygunstudio.com and I'll post it via wetransfer. Thank you!

                          • 10. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                            iamwickedtall1 Level 1

                            I emailed to you, and as well used the code markup feature of the forums, and included instructions.

                            • 11. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                              Stephen_A_Marsh Adobe Community Professional

                              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.

                              • 12. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                吴晓睿 Level 1

                                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.

                                • 14. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                  seanh86913514 Level 1

                                  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?

                                  • 15. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                    gener7 Adobe Community Professional & MVP

                                    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.

                                    • 16. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                      Stephen_A_Marsh Adobe Community Professional

                                      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!

                                      1 person found this helpful
                                      • 17. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                        gener7 Adobe Community Professional & MVP

                                        Thanks Stephen. I rushed that one answer out and missed that detail.

                                        • 18. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                          Stephen_A_Marsh Adobe Community Professional

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

                                           

                                          Prepression: Metadata Bloat – photoshop:DocumentAncestors

                                          • 19. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                            jj_graphic_jj Level 1

                                            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.

                                            • 20. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                              iamwickedtall1 Level 1

                                              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.

                                              • 21. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                Stephen_A_Marsh Adobe Community Professional

                                                • 22. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                  D Fosse Adobe Community Professional & MVP

                                                  Side note re InDesign: If you really want to clean up an ID document, export to IDML and reopen, save as new .indd document. This clears out all kinds of accumulated junk. It's a standard troubleshooting procedure.

                                                  • 23. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                    iamwickedtall1 Level 1

                                                    Stephen_A_Marsh  wrote

                                                    Thanks for the clarification! In the link I posted, [Jongware] mentioned it was undo information that built up over time. Since Doc Ancestors contain copy paste information and other artifacts, my thought was that they were similarly stored. I'm now wondering if one could scrub this inflation in InDesign via scripting...

                                                    • 24. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                      elmimmo Level 1

                                                      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.

                                                      • 25. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                        Stephen_A_Marsh Adobe Community Professional

                                                        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.

                                                        • 26. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                          iamwickedtall1 Level 1

                                                          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.

                                                          • 27. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                            Stephen_A_Marsh Adobe Community Professional

                                                            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.

                                                            • 28. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                              iamwickedtall1 Level 1

                                                              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?

                                                              • 29. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                                Stephen_A_Marsh Adobe Community Professional

                                                                You don’t mention PNG... Did you actually try PNG? This is what the addendum post is all about, not other formats.

                                                                 

                                                                Save for web and export to PNG strip metadata, so this is not an issue. A regular save as PNG will retain the metadata and running these scripts on PNG does appear to mangle the metadata and not work as expected.

                                                                • 30. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                                  elmimmo Level 1

                                                                  iamwickedtall1, the results that I report refer to when applying those solutions exclusively to PNG files. Here, I rephrase it all to make it clearer:

                                                                  • Photoshop or Bridge scripts do not work on PNG files. They do alter the PNG, but substituting, instead of deleting, the thousands of Document Ancestors with thousands of lines filled with spaces, therefore maintaining its approximate file size. Applying exiftool to the PNG after it has been unsuccessfully processed by the Photoshop or Bridge scripts, in a manner (i.e. command-line arguments) that it deletes only Document Ancestors, accomplishes nothing either, since the file has no Document Ancestor metadata anymore.
                                                                  • Exiftool does work bulletproof to affected PNGs that have not been previously tampered with by the Photoshop or Bridge scripts.

                                                                  iamwickedtall1 wrote:

                                                                  I exported my XMP via bridge and didn't see an issue even in text editor

                                                                  For what it's worth, the XMP of a PNG that has unsuccessfully been processed by the Bridge script, if exported via Bridge (menu File > File Info… > Export…), does not contain those thousands of lines filled with spaces that I report the Bridge script substituted Document Ancestor metadata with. But they are there if the XMP is exported via exiftool. And since, at any rate, the file size of the PNG processed by the Bridge script remains huge, I take the XMP exported by exiftool is the reliable one.

                                                                  • 31. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                                    iamwickedtall1 Level 1

                                                                    Forgot to include PNG, but yes that works fine as well. I have yet to find a format that doesn't execute the script properly.

                                                                    • 32. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                                      iamwickedtall1 Level 1

                                                                      Thanks for going into further detail. I cannot speak to the Bridge Script as I only solved for Photoshop. In Bridge, I'm wondering if the file needs to be saved via another method to reflect the changes to the xmp before letting go of that space in the file. As far as which xmp data is correct, it seems something unexpected is happening with exif tool that would need to be addressed. I did a quick test, taking a png with doc ancestors, and one that had been saved out running the script through photoshop, and changing both extensions to xmp and opening in text edit. In both cases, there were 120 lines between </x:xmpmeta><?xpacket end="w"?>. The main difference being the file with ancestors had an addition 66110 lines of code. As the information has been successfully scrubbed from the file, it would seem there needs to be additional handling on the exifTool end, where Adobe is potentially creating some hidden issues within their code.

                                                                      • 34. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                                        elmimmo Level 1

                                                                        iamwickedtall1  escribió

                                                                         

                                                                        Forgot to include PNG, but yes that works fine as well. I have yet to find a format that doesn't execute the script properly.

                                                                        I checked again and indeed Solution #1: Adobe Photoshop Script (v. 17.0.0 a.k.a 2015.5) does work on PNGs just fine. Go figure. I might have missed something when I checked originally.

                                                                         

                                                                        Nevertheless, Solution #2: Adobe Bridge Script (v. 6.2.0.179) and Addendum – Solution #5: Adobe Photoshop Script (v. 17.0.0 a.k.a 2015.5) still did not work this time either, resulting in the same effect I described above: a modified PNG that remains unnaturally huge but has no Document Ancestor metadata anymore.

                                                                         

                                                                        For reference, this is the PNG file I used, a whooping 13 MB file for a canvas of a mere 100px2. (Update: I accidentally uploaded a version processed by the Bridge script therefore still inflated but lacking Document Ancestor metadata; after I noticed, I changed the link to point to a non-processed file therefore with its Document Ancestor metadata intact).

                                                                        • 35. Re: Inflated JPG File Size  - Photoshop Document:Ancestors Metadata
                                                                          Stephen_A_Marsh Adobe Community Professional

                                                                          Go figure. I might have missed something when I checked originally.

                                                                           

                                                                          It is strange, I’m sure the same thing happened to me! When I first checked, it did not work, then the next time it did…