5 Replies Latest reply on May 30, 2010 1:53 PM by Tom Tomasko

    checking graphics

    Mickeske

      hey,

       

      i need some help. I want to check my artworks by clicking on 1 script. I want to check if the graphics is totally in de graphic-content. Sometimes when i use the white pen en select some graphics, i see that the graphics is sometimes bigger then the frame. could someone help me. which command do i need?

       

      Can i put some graphic on an alertbox? and if possible, how?

       

      tnx

        • 1. Re: checking graphics
          Peter Kahrel Adobe Community Professional & MVP

          InDesign version? Script language?

           

          Anyway, your general approach would be I guess to compare the graphic's geometric bounds with those of its containing rectangle. In JaveScript something like this:

           

          if (myGraphic.geometricBounds != myGraphic.parent.geometricBounds)

             // then they're not the same size or position

           

          Peter

          1 person found this helpful
          • 2. Re: checking graphics
            Mickeske Level 1

            tnx, you're solution looks very easy to use.. ( I'am new in the world of javascript)

             

            which tutorial is the best to use???

            • 3. Re: checking graphics
              Peter Kahrel Adobe Community Professional & MVP

              Well, I would (immodestly) say this one: http://oreilly.com/catalog/9780596802523/

               

              Peter

              • 4. Re: checking graphics
                [Jongware] Most Valuable Participant

                I wrote a similar script last month: Script for identifying undersized graphics frames?

                 

                It identifies the frames by adding a thick red outline around them. You can check the graphics by eye, then manually remove the red stroke.

                • 5. Re: checking graphics
                  Tom Tomasko Level 1

                  The following script will check to see if all of the graphics have been sized to 100% both horizontally and vertically. It sometimes gives the printer headaches if the photos are resized in InDesign rather than in PhotoShop. The script also looks for any color profiling. If you want absolute control over the colors, then it is best not to have any color profiles embedd in the photos.

                   

                  Tom

                   

                  //several alert builders
                  var alertTop = "Oh, oh. The following image(s) are not at 100% scale or there is ICC profile embedded.\r";
                  var alertBottom ="\r\rPlease copy this info and fix scale of tifs or the ICC profile in Photoshop. Eps's not at 100% scale do not have to be fixed. If the ICC Profile is \"Use Document Default\" and the scale is 100% you should check it out in PhotoShop. But if scale is other than 100%, ignore for now.\r\rIf you would like to create a text file of this info, click \"Yes\". The file will be in a folder called \"GraphicsCheck\" on your Desktop.";
                  var alertReICC = "If the ICC Profile is \"Use Document Default\" and the scale is 100% you should check it out in PhotoShop. But if scale is other than 100%, ignore for now.\r\r"

                   

                  detectGroupsOrPasteBoardImages();
                  var  report = checkImageScale();
                  if(report.length == 0){
                      alert("There are no problems with the images. Good work!");
                      }//end if length ==0
                  else if(report.length >= 1 && report.length<= 6){
                      var userResponse = confirm(alertTop+alertText()+alertBottom);
                      if(userResponse == true){
                          createTextFile(alertReICC+alertText());
                          }//end if userResponse
                      }//end if length >1&&=<6
                  else if(report.length > 6){
                      var alertTooBig =confirm("There are more than six images wrongly scaled and/or with ICC profile. This alert might go off the screen if I listed them all here. Please click Yes to create a text file with all problems noted. The file will be in a folder called \"GraphicsCheck\" on your Desktop.",false,"Image scale finder");
                      if(alertTooBig == true){
                          createTextFile(alertReICC+alertText());
                          }//end if true
                      }//end if length >6
                     
                  //*****functions*****
                  //This will detect if there are Groups of Groups of Images or images on the pasteBoard and give an alert to the user.
                  function detectGroupsOrPasteBoardImages(){
                      var imagesOnPasteBoard = [];
                      var g = app.activeDocument.allGraphics;
                      for (var k = 0; k < g.length; k++){
                          if(g[k].itemLink.parent.parent.parent.constructor.name == "Spread"){
                                  imagesOnPasteBoard.push(g[k]);
                                  }//end if
                      }//end for k
                      var groupsOfGroups = [];
                      for (var m = 0; m < g.length; m++){
                          if(g[m].itemLink.parent.parent.parent.parent.constructor.name == "Group"){
                                  groupsOfGroups.push(g[m]);
                                  }//end if
                      }//end for k
                      if(imagesOnPasteBoard.length ==0&&groupsOfGroups.length >=1){
                          alert("Images that may hang up this script:\r\rYou have "+groupsOfGroups.length+" images in Groups of Groups.\r\rYou must Ungroup the double groups before this script can do its magic.")
                          }//end if imagesOnPasteBoard.length = 0
                      else if(groupsOfGroups.length ==0&&imagesOnPasteBoard.length >=1){
                          alert("Images that may hang up this script:\r\rYou have "+imagesOnPasteBoard.length+" image(s) on the paste board.\r\rYou must move all the images on the paste board on to pages (or delete them) before this script can do its magic.")
                          }//end if imagesOnPasteBoard.length = 0
                      else if(groupsOfGroups.length >=1&&imagesOnPasteBoard.length >=1){
                  alert("Images that may hang up this script:\r\rYou have "+imagesOnPasteBoard.length+" image(s) on the paste board.\r\rYou also have "+groupsOfGroups.length+" images in Groups of Groups.\r\rYou must move all the images on the paste board on to pages (or delete the images) and Ungroup the double groups before this script can do its magic.");
                  }//end if both arrays have length > 0
                      else{return;}//end else
                  exit();
                      }//end detectGroupsorPasteBoardImages()   
                     
                  function checkImageScale(){
                      arrBadImages = [];
                      var g = app.activeDocument.allGraphics;
                      for (var i = 0; i < g.length; i++){
                          var fileName = File(g[i].itemLink.filePath).name;
                          var scaleVert = g[i].itemLink.parent.absoluteVerticalScale;
                          var scaleHor = g[i].itemLink.parent.absoluteHorizontalScale;
                          try{
                              var colorProfile = g[i].profile;
                              }//end try
                          catch(e){/*do nothing*/}
                      if( scaleVert != 100||scaleHor != 100||colorProfile == "Embedded"){
                              arrBadImages.push(g[i]);
                              }//end if !=100
                      }//end for i
                      return arrBadImages;
                  }//end function checkImageScale

                   

                  function alertText(){
                      var linkErrors = "";
                      for(var j = 0; j< report.length; j++){
                          var linkName = report[j].itemLink.name;
                          var scaleVert = report[j].absoluteVerticalScale.toFixed(4);
                          var scaleHorz = report[j].absoluteHorizontalScale.toFixed(4);
                          try{
                              var colorProfile = report[j].profile;
                              }//end try
                          catch(e){/*do nothing*/}
                      if(report[j].itemLink.parent.parent.parent.constructor.name == "Group"){
                          var pageNumber = report[j].itemLink.parent.parent.parent.parent. name;
                          }//end if
                      else {var pageNumber = report[j].itemLink.parent.parent.parent.name;}
                          linkErrors+= "Page: "+pageNumber+" \rLink: "+linkName+ "\rVertical scale: "+scaleVert+ "\rHorizontal scale: "+scaleHorz+"\rICC Profile: "+colorProfile+"\r\r"
                  }//end for j
                  return linkErrors;
                  }//end alertText

                   

                  function createTextFile(someText){
                      var folderPath = Folder("~/Desktop");
                      var folderName = "GraphicsCheck";
                      var activeDocName = app.activeDocument.name.slice(0,-4);
                      var fileName = activeDocName+"ScaleProblems.txt";
                      var filePath = folderPath+"/"+folderName+"/"+fileName;
                      Folder(folderPath+"/"+folderName).create();
                      var myFile = new File(filePath);
                      myFile.open("w", "TEXT");
                      myFile.write(someText);
                      myFile.close();
                  }//end function createTextFile