2 Replies Latest reply on Jun 28, 2010 11:56 PM by John J David

    Generate images list out of InDesign CS4

    John J David Level 1

       

      We have an InDesign CS4 document that had more images. Most of them have been reduced to some percentage to fit the page. I need to generate a report TXT/RTF format of the resized images alone. Kindly help me is there any script that had already to meet the requirement?


        • 1. Re: Generate images list out of InDesign CS4
          Kasyan Servetsky Level 5

          I knocked this off for about 10 minutes, so it's totally untested. The script creates a text file on the desktop listing resized images in the active document and their scaling.

           

          Kasyan

           

          var kScriptName = "Generate list of resized images";
          if (app.documents.length == 0) ErrorExit("No documents are open. Please open a document and try again.");
          
          var doc = app.activeDocument;
          var links = doc.links;
          var counter = 0;
          var resizedImages = [];
          
          for (var i = 0; i < links.length; i++) {
               var image = links[i].parent;
               if (image.absoluteHorizontalScale != 100 || image.absoluteHorizontalScale != 100) {
                    resizedImages.push(image);
               }
          }
          
          if (resizedImages.length == 0) {
               alert("No resized images were found.", kScriptName);
          }
          else {
               WriteToFile("\r--------------------- Script started -- " + GetDate() + " ---------------------\n");
               WriteToFile(doc.name + "\n");
               
               for (var j = 0; j < resizedImages.length; j++) {
                    var currentImage = resizedImages[j];
                    var info = (j+1) + " - " + currentImage.itemLink.name + "\t" + Math.round(currentImage.absoluteHorizontalScale) + "x" + Math.round(currentImage.absoluteHorizontalScale) + " %\r";
                    WriteToFile(info);
               }
          
               WriteToFile("\r--------------------- Script finished -- " + GetDate() + " ---------------------\r\r");
               
               alert(resizedImages.length + " resized images were found.", kScriptName);
          }
          
          //-------------------------------------- FUNCTIONS ---------------------------------------------
          function WriteToFile(text) {
               var theFile = new File("~/Desktop/" + kScriptName + ".txt");
               if ( theFile.exists ) {
                    theFile.open("e");
                    theFile.seek(0, 2);
               }
               else {
                    theFile.open("w");
               }
               theFile.write(text); 
               theFile.close();
          }
          //--------------------------------------------------------------------------------------------------------------
          function ErrorExit(myError, myIcon) {
               alert(myError, kScriptName, myIcon);
               exit();
          }
          //--------------------------------------------------------------------------------------------------------------
          function GetDate() {
               var myDate = new Date();
               if ((myDate.getYear() - 100) < 10) {
                    var myYear = "0" + new String((myDate.getYear() - 100));
               } else {
                    var myYear = new String ((myDate.getYear() - 100));
               }
               var myDateString = (myDate.getMonth() + 1) + "/" + myDate.getDate() + "/" + myYear + " " + myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds();
               return myDateString;
           }
          //--------------------------------------------------------------------------------------------------------------
          

           

          P.S. Written on CS3, Windows

          • 2. Re: Generate images list out of InDesign CS4
            John J David Level 1

            Thanks a lot Kasyan. Really it is helpful and correct answer.