6 Replies Latest reply on Mar 14, 2017 3:44 AM by rachellefacistolmata

    Export Indesign images with their clipping paths

    rachellefacistolmata Level 1

      Hi! I am new to Indesign. I have a file that contains images with Photoshop clipping paths. I want to export all the clipped images in a folder. I have tried doing the "Copy Links To" and it successfully exported the original images. However, I do not want the original images but the clipped images instead. Is there a way for me to export all the clipped images as JPEG or TIFF and not the original linked image? In short, I want to export the images without their background. Or maybe export each image (with its corresponding clipping path) as a file, then I'll just convert them in Photoshop. I hope I'm making sense.

       

      I hope there's a way to do this. I have about 800 images so a batch processing method would be highly appreciated.
      Thank you!

        • 1. Re: Export Indesign images with their clipping paths
          rachellefacistolmata Level 1

          I actually found a way to export the images the way I want them to be. I just need to click the image container (not the image), go to File>Export and then export it as JPEG. It exports the images the way I want them to be. I just have two concerns:
          1. Is there a way for me to do this by batch? Like select all the image containers and export them one by one?
          2. Is there a way to automatically name the saved files according to the original image name?

          • 2. Re: Export Indesign images with their clipping paths
            Steve Werner Adobe Community Professional & MVP

            It's possibly scriptable. If you don't get an answer here, ask in the InDesign Scripting forum:

             

            InDesign Scripting

            1 person found this helpful
            • 3. Re: Export Indesign images with their clipping paths
              Migintosh Level 4

              Here are a few things to consider. A Photoshop image can have many clipping paths, or no clipping path. Once placed into InDesign, you can select the image and go to Object>Clipping Path>Options and select from the number of clipping paths the image has. So, your Photoshop images probably already have clipping paths.

              • 4. Re: Export Indesign images with their clipping paths
                vinny38 Level 4

                Hi

                Maybe something like that could help (based on an existing script):

                 

                var myDoc = app.activeDocument,
                  apis = myDoc.allPageItems, items, fileName;
                
                while (items = apis.pop()) {
                  if (!(items instanceof Rectangle) && !(items instanceof Oval) && !(items instanceof Polygon) || !items.graphics[0].isValid) {
                  continue;
                  }
                
                  fileName = File(items.graphics[0].itemLink.filePath).name;
                  fileName = fileName.replace(/\.[a-z]{2,4}$/i, '.jpg');
                
                  app.jpegExportPreferences.exportResolution = 2400;
                  app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;
                
                  var myFile = new File("C:/YourPath/YourFolder/" + fileName);
                
                  items.exportFile(ExportFormat.JPG, myFile);
                }
                
                1 person found this helpful
                • 5. Re: Export Indesign images with their clipping paths
                  rachellefacistolmata Level 1

                  Hi Vinny,
                  Thank you for your suggestion. I have tried your modification and it works, almost. I have one more concern though. Not all of my linked images are in a rectangles, polygons or ovals. Some of them are in arbitrary shapes (like the clipping path followed the edges of the image). Can you suggest a way for me to catch those instances too?

                  Thanks!

                  • 6. Re: Export Indesign images with their clipping paths
                    rachellefacistolmata Level 1

                    Thank you for your inputs. I have combined all the answers I got from all the different forums I asked help from and finally came up with a script that iterates only through the linked images and disregards whether the container is a rectangle, polygon, or whatever. I also added a counter s !o that the images won't get overwritten in case the names are the same.

                     

                     

                        var myDoc = app.activeDocument,

                        apis = myDoc.links.everyItem().getElements(), items, fileName;

                        var i = 0;

                     

                     

                        while ( items = apis.pop() )

                        {

                            items = items.parent.parent; 

                            if ( !(items.hasOwnProperty ("graphics") )){ continue; }

                            i++;

                         try{

                                fileName = File ( items.graphics[0].itemLink.filePath ).name;

                                fileName =  i + "_" + fileName.replace( /\.[a-z]{2,4}$/i, '.jpg' );

                         }catch(e){};

                       

                            app.jpegExportPreferences.exportResolution = 2400;

                            app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;

                     

                     

                            //give it a unique name

                            var myFile = new File ("Mypath"+ fileName);

                     

                     

                            items.exportFile(ExportFormat.JPG, myFile);

                        }