3 Replies Latest reply on Sep 17, 2009 3:00 AM by Techi Panda

    Get image height and width

    Techi Panda Level 2

      Hi scripters


      I am trying to get the width and height of my image file. Here is my code


      myPicFile = File("c:\\ar.eps");

      h = myPicFile.height;

      w = myPicFile.width;



      This code throws error

      Script Alert

      how can I get the height and widht of my image? is there any other method?


      thanks in advance



      a r u l

        • 1. Re: Get image height and width
          Adobe-InDesign CS4 Level 1

          Dear Arul,


          Here my code is in InDesign Based. I don't know we are getting the Image size directly.?


          Throught InDesign [you using the InDesign Script then] Script here I pasted the below coding...



          //============================= Getting the Image Height / Width ============================//


          var myDoc = app.activeDocument;

          myPicFile = File("E:\\HariharaSudhan\\Blue hills.jpg");




          //======================== Then u please select the Image File in InDesign and then you run the script ===============//

          var mySel = app.selection[0];

          var Bound = mySel.geometricBounds;

          var height = Bound[2] - Bound[0];
          var width = Bound[3] - Bound[1];


          alert("Image Height :"+ height +" "+"Image Width :"+ width );


          //============================= End  : Getting the Image Height / Width ============================//


          Please let me know if you have any queries.


          Thanks & Regards

          T.R.Harihara SudhaN

          • 2. Re: Get image height and width
            Thomas B. Nielsen Level 3

            You are mixing things up.


            myPicFile is a file Object - look in the ESTK under Help -> Core Javascript Classes -> File to see what you have available for this object type.


            If you have an image or graphic that is placed in Indesign you should use myPicFile.geometricBounds // myPicFile must be a valid graphic or image item.

            1 person found this helpful
            • 3. Re: Get image height and width
              Techi Panda Level 2

              Thanks T.R.Harihara SudhaN & Thomas B. Nielsen i learned.


              thanks again



              a r u l