6 Replies Latest reply on Aug 15, 2013 1:22 AM by rajnikids

    find images resolution

    rajnikids Level 1

      Hi Forum,

       

      I have tried to get alert for the links if it has 250 or 300 resolution. But if the pdf is placed, the script is replying error message.

      "object does not support the property or method actualPPi"

       

      How can i omit the check for PDF and continue to find other images resolution and alert.

       

       

       

      var doc = app.activeDocument;

      var graphics = doc.allGraphics;

       

      var image, horRes, verRes;

       

      for (var i = 0; i < graphics.length; i++) {

           image = graphics[i];

           if(image.actualPpi[0] ==300 ||

           image.actualPpi[0] ==250){

      alert ("images are in 300 & 250 dpi");                 

                }

           

           }

       

       

      thanks in advance forum...

        • 1. Re: find images resolution
          -hans- Level 4

          for example check with hasOwnProperty('actualPpi') != false and then start over

          • 2. Re: find images resolution
            rajnikids Level 1

            hi -hans-

             

            thanks for the quick reply,

             

            on the flip side of it, it tried to check only for the "Grayscale" images. please see and if you can help on this...

             

            var doc = app.activeDocument;

             

            var graphics = doc.allGraphics;

             

             

             

            var image, horRes, verRes;

             

             

             

            for (var i = 0; i < graphics.length; i++) {

             

                 image = graphics[i];

             

                 if(image.imageTypeName == 'Grayscale' &&

                 image.hasOwnProperty('actualPpi') != false &&

             

                 image.actualPpi[0] ==250){

             

            alert ("images are in 300 & 250 dpi");                

             

                      }

             

                

             

                 }

            • 3. Re: find images resolution
              -hans- Level 4

              imageTypeName won't return the colorspace.

              try aSampleImageReference.space and check what you'll get ...

              • 4. Re: find images resolution
                rajnikids Level 1

                hi -hans-

                thanks for your support.

                 

                did you mean.

                 

                  if(image.space == 'Grayscale')

                {

                alert("Grayscale")

                }

                 

                after using this,,, i could reply... [object-name] in ESTK but not alerts.

                • 5. Re: find images resolution
                  -hans- Level 4
                  var allPics = app.activeDocument.allGraphics;
                  l = allPics.length;
                  
                  while(l--)
                  {
                      var currGraphic = allPics[l];
                  if(currGraphic.hasOwnProperty('actualPpi'))
                  {
                  
                      var checkSpace = currGraphic.space;//unfortunately a local String is returned: PLEASE CHECK what your version returns for Grayscale ...
                      
                      switch(checkSpace)
                      {
                  case 'Grayscale' : var picOrigRes = currGraphic.actualPpi; currGraphic.parent.select(); alert('Here Grayscale! \n Originalresolution: ' + picOrigRes); break;
                  default : break;
                              }
                          
                      }
                          }
                  
                  • 6. Re: find images resolution
                    rajnikids Level 1

                    Thanks thanks thanks thanks a ton & ton...

                     

                    I notice i have misspelled the word "Grayscale" "a" should be replaced by "e".

                     

                    Many thanks -hans-.......