2 Replies Latest reply on Aug 11, 2014 5:06 PM by tusharde

    Filtering images from the selection

    tusharde Level 1

      I am writing a script that involves scaling and sorting images. Which means i have to access the geometricBounds property of the images. Now, when the selection contains either an EPS or PDF file the script fails.

      So i am trying to filter through the selection array to find images that are NOT EPS or PDF. I noticed that EPS and PDF files don't have geometricBounds. So i was trying to use that property to sort it. But i am running into issues. Any thoughts? Solutions?

       

      if(app.documents.length != 0){
        if(app.selection.length != 0){
        for(myCounter = 0; myCounter < app.selection.length; myCounter++){
        switch(app.selection[myCounter].constructor.name)
        {
        case "GraphicLine":
        case "Oval":
        case "Polygon":
        case "Rectangle":
        if(app.selection[myCounter].contentType != ContentType.UNASSIGNED){ // checks to make sure frame contains an image.
              
           if(app.selection[myCounter].graphics[0].geometricBounds[0]) { // checks to see if image has a width property. else it avoids it.
                 myObjectList.push(app.selection[myCounter]);
           }
      
      
        }
        break;
        }
        }
        if(myObjectList.length !=0){
                          openDialog(myObjectList, keyObj);
        // moveItems(myObjectList);
        }
        } else {alert("Select some images, fool!")}
      }
      
      
        • 1. Re: Filtering images from the selection
          Jump_Over Level 5

          I noticed that EPS and PDF files don't have geometricBounds.

           

          Hi,

           

          Both do - check Object Model.

          Looks like there is another reason as your script fails. Cant say more without details.

           

          Notice that PDF and EPS is a standalone class (alike Image is) ==> so one does not include another.

           

          Jarek

          • 2. Re: Filtering images from the selection
            tusharde Level 1

            Thanks Jarek. You're right. I came to that conclusion after i found another solve for the core problem that led me down this road.

            I decided to apply all transformations to the "graphics" object, rather than images alone. Graphics includes eps and pdf. Which revealed to me that those two have geometricBounds too.

             

            thanks for your reply.

            appreciate it.