22 Replies Latest reply: Dec 28, 2009 8:49 AM by pkahrel RSS

    Convert embedded image to a linked

    ColinBooth777

      I have a large file, with hundreds of embedded images.  Is there a way to make each export into its own file so that they are all linked, and therefore the file is much smaller and more manageable?

        • 1. Re: Convert embedded image to a linked
          BobLevine UGM

          Select the links in the links panel and from the links panel menu select unembed link.

          • 2. Re: Convert embedded image to a linked
            pkahrel MVP

            I use the script listed below for that.

             

            Peter

             

            // Unembed images without links: write them to disk and create a link
            // Images are saved as JPEGs in the document's folder using the name
            // "unembedded_" followed by a sequential number

            try {unembed_images ()}
                catch (e) {alert (e.message + "\r(line " + e.line + ")")};

            function unembed_images ()
                {
                // Alternative: baselineEncoding
                app.jpegExportPreferences.jpegRenderingStyle =  JPEGOptionsFormat.progressiveEncoding;
                // Options: maximum, high, medium, low
                app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.maximum;
                // Any resolution
                app.jpegExportPreferences.resolution = 300;
                var output_folder = String (app.documents[0].filePath);
                var g = app.documents[0].allGraphics;
                for (var i = 0; i < g.length; i++)
                    {
                    if (g[i].itemLink == null)
                        {
                        var image = File (output_folder + "/unembedded_" + String (i) + ".jpg");
                        g[i].exportFile (ExportFormat.jpg, image);
                        g[i].parent.place (image);
                        }
                    }
                }
            • 3. Re: Convert embedded image to a linked
              pkahrel MVP

              Bob's method is better if you can see filenames in the Links panel. But if you can't see any links, which is usually the case when images had been pasted into InDesign, then the script can be used.

               

              Peter

              • 4. Re: Convert embedded image to a linked
                ColinBooth777 Community Member

                Sorry to be a pest... how exactly do I run that?  I've only scripted in non-adobe programs; Rhino 3D and AutoCAD

                • 5. Re: Convert embedded image to a linked
                  BobLevine UGM

                  If there are no links in the panel, then all you'll have is very low res preview images. Turning those into links will do nothing to improve the quality.

                   

                  Bob

                  • 6. Re: Convert embedded image to a linked
                    pkahrel MVP

                    Copy the text of a script into a plain-text editor (such as Notepad on Windows) and save it using any name but with the extension .jsx in your scripts folder. To find out where that folder is and how to run the script, see here:

                    http://www.kahrel.plus.com/indesign/script-info.html#scriptlocations

                     

                    Peter

                    • 7. Re: Convert embedded image to a linked
                      Printer_Rick Community Member

                      A pasted image (which does not show up in Links panel) is not a preview, and the resolution of the original image is preserved. However the pasted image is always RGB.

                       

                      Not trying to condone pasting images. It is bad practice – it bloats the file, the source image name is lost, and there is no direct means to edit the image in Photoshop.

                      • 8. Re: Convert embedded image to a linked
                        Peter Spier ACP/MVPs

                        An image pasted from Photoshop, at least on Windows, IS, most emphatically, not full resolution (though as I recall, the Info panel erroneously reports the resolution of the original). I believe the problem exists on Mac as well, thought he info panel may behave differently. I can't speak about other sources because I don't paste images and haven't tested.

                         

                        I've attached a PDF of a demonstration file I made for my classes.

                        • 9. Re: Convert embedded image to a linked
                          Printer_Rick Community Member

                          Just did a paste vs. place test and exported to PDF (on a mac). Images are same resolution in Acrobat, 300 PPI. Since the placed image was RGB they look identical in the PDF.

                           

                          (Side note for color management nerds – if you paste a grayscale image, the result is the same as assigning Gray Gamma 2.2 profile in Photoshop, then converting to the InDesign document RGB color space. ID has no gray color management and defaults to Gray Gamma 2.2)

                           

                          My big question is, why in the world don't the pasted images show up in the Links panel? I never paste images myself but I come across pasted images all the time. It would be ideal if InDesign showed them as embedded links, instead of letting them float on the page without any identification.

                           

                          I really like the script posted earlier but I wish it saved out the images as TIFF instead of JPEG.

                          • 10. Re: Convert embedded image to a linked
                            BobLevine UGM

                            I'm sorry, Rick. I don't know what you're doing or looking at but pasting an image is most certainly NOT going to give you a full resolution graphic. It's a low res screen preview and ID can't link to something that's only sitting on the clipboard.

                             

                            Bob

                            • 11. Re: Convert embedded image to a linked
                              Peter Spier ACP/MVPs

                              Pasting a previously placed image would give you full res -- in essence you are pasting the pointer to the image...

                              • 12. Re: Convert embedded image to a linked
                                pkahrel MVP

                                Peter,

                                 

                                I did the same test that Rick did: copied a high-res image in PS, pasted that in ID, then placed the same image. So I had a document with two images that looked the same, but with just one link in the Links panel. When I exported this to PDF (press quality setting), the images took equally long to process, and later in Avrobat I couldn't see any difference between the two (see attached file). So I got the same results as Rick.

                                 

                                Your test shows clear differences. Do you have any idea why your test comes out different? I'm curious -- I don't know very much about images and resolution.

                                 

                                Thanks,

                                 

                                Peter

                                • 13. Re: Convert embedded image to a linked
                                  Peter Spier ACP/MVPs

                                  Well, what do you know. Here's a lesson in not relying on past experience with old technology.

                                   

                                  The PDF I posted above was made several years ago for a calss I used to teach, and at the time CS3 was state of the art. The file was created in Windows, and I know something was different about what happened on Mac -- I think it was the resolution reporting in the info panel, but I really don't remember. There is no question there was a probelm then. I may even have reported it as a bug.

                                   

                                  Fast forward to the present. I just repeated the test myself using CS3 (5.0.4) and the resoluion issue is still present, and in CS4 (6.0.4) and you guys are correct -- the pasted image is now full res. It is still RGB, however, when the original is CMYK. Apparently the clipboard handling is fixed, at least to a degree, and I'll change my rant in the future.

                                   

                                  Thanks for the update to both Peter K and Rick.

                                  • 14. Re: Convert embedded image to a linked
                                    pkahrel MVP

                                    An easier test could be this: copy/paste an image, unembed it using the script, and see what size it is. I tested with a JPG file 4,687,585 bytes long. When pasted in an ID document and written to disk by the script it was 3,828,529 bytes. The script used the current JPEG settings of maximum quality, 300 ppi.

                                     

                                    So it came out a bit smaller -- don't know what that means.

                                     

                                    Peter

                                    • 15. Re: Convert embedded image to a linked
                                      pkahrel MVP

                                      > I wish it saved out the images as TIFF instead of JPEG.

                                       

                                      Unfortunately that's not possible. The only options are JPG, EPS, and PNG. I forgot to mention that the JPG settings used are the application's current settings.

                                       

                                      Peter

                                      • 16. Re: Convert embedded image to a linked
                                        Peter Spier ACP/MVPs

                                        pkahrel wrote:

                                         

                                        An easier test could be this: copy/paste an image, unembed it using the script, and see what size it is. I tested with a JPG file 4,687,585 bytes long. When pasted in an ID document and written to disk by the script it was 3,828,529 bytes. The script used the current JPEG settings of maximum quality, 300 ppi.

                                         

                                        So it came out a bit smaller -- don't know what that means.

                                         

                                        Peter

                                        I think it means that the image is being re-compressed, just as it would be if you resaved a jpeg as a new jpeg file in Photoshop.

                                         

                                        Peter

                                        • 17. Re: Convert embedded image to a linked
                                          Peter Spier ACP/MVPs

                                          pkahrel wrote:

                                           

                                          > I wish it saved out the images as TIFF instead of JPEG.

                                           

                                          Unfortunately that's not possible. The only options are JPG, EPS, and PNG. I forgot to mention that the JPG settings used are the application's current settings.

                                           

                                          Peter

                                          Peter,

                                           

                                          Here's a really ugly scenario, but something to think about. Can you export as .eps, open those in Photoshop and save there to a new folder as either tiff or psd, then "relink to folder" in ID? I know you could do the conversion as a batch in Photoshop and relink in ID as separate operations, but I don't know enough about scripting to know if an ID script would be able to handle it.

                                           

                                          Peter

                                          • 18. Re: Convert embedded image to a linked
                                            BobLevine UGM

                                            Quite the advancement. Perhaps to filed along with the advancement in pulling graphics out of Word files.

                                             

                                            Peter K, can that script be changed to save as PNG? Might be a safer file format as far as compression goes.

                                             

                                            Bob

                                            • 19. Re: Convert embedded image to a linked
                                              pkahrel MVP

                                              > Here's a really ugly scenario ...

                                               

                                              You can't script that from within InDesign, but PhotoShop has an image processor (File > Scripts > Image Processor). This is a script that ships with PS (CS3, don't know about CS4). You can convert all images by the folder to JPG, PSD and TIFF. Works very well.

                                               

                                              Peter

                                              • 20. Re: Convert embedded image to a linked
                                                pkahrel MVP

                                                Change the highlighted items in these two lines:

                                                 

                                                var image = File (output_folder + "/unembedded_" + String (i) + ".jpg");
                                                g[i].exportFile (ExportFormat.jpg, image);

                                                 

                                                to this:

                                                 

                                                var image = File (output_folder + "/unembedded_" + String (i) + ".png");
                                                g[i].exportFile (ExportFormat.pngFormat, image);

                                                 

                                                I'll put something together with some dialog to pick a format.

                                                 

                                                Peter

                                                • 21. Re: Convert embedded image to a linked
                                                  pkahrel MVP

                                                  > You can't script that from within InDesign,

                                                   

                                                  That wasn't very clear. You'd first unembed all pasted images in InDesign. To do that, in the script change the highlighted items in these two lines:

                                                   

                                                  var image = File (output_folder + "/unembedded_" + String (i) + ".jpg");
                                                  g[i].exportFile (ExportFormat.jpg, image);

                                                   

                                                  like this

                                                   

                                                  var image = File (output_folder + "/unembedded_" + String (i) + ".eps");
                                                  g[i].exportFile (ExportFormat.epsType, image);

                                                   

                                                  Then you run the Image processor script in PhotoShop.

                                                   

                                                  Peter

                                                  • 22. Re: Convert embedded image to a linked
                                                    pkahrel MVP

                                                    Here's the script mentioned earlier: http://www.kahrel.plus.com/indesign/dump_pasted_images.html

                                                     

                                                    Peter