1 Reply Latest reply on Jul 7, 2011 1:20 AM by 2i_Geert

    Major Derp: Get Dimensions of Placed Image

    jeffmlevy Level 1

      Given a rectangle with a placed graphic, set fit proportional, How do I go about getting the actual height & width of my placed image?


      My image is being scaled down to fit the box. I can see that in my output. I'm not sure which object(s) to query, and what properties to query to get the actual original image dimensions.



        • 1. Re: Major Derp: Get Dimensions of Placed Image
          2i_Geert Level 1



          Do you mean something like this:


          var document = app.activeDocument;

          document.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.POINTS;
          document.viewPreferences.verticalMeasurementUnits = MeasurementUnits.POINTS;

          var image = document.rectangles[0].images[0];
          var link = image.itemLink;
          var xScale = (image.effectivePpi[0] / 72);
          var yScale = (image.effectivePpi[1] / 72);

          $.writeln("Image: " + link.filePath);
          $.writeln("Width: " + Math.floor((image.geometricBounds[3] - image.geometricBounds[1]) * xScale));
          $.writeln("Height: " + Math.floor((image.geometricBounds[2] - image.geometricBounds[0]) * yScale));

          1 person found this helpful