5 Replies Latest reply on Jan 23, 2011 1:28 AM by Kasyan Servetsky

# Height and width of graphic in pixels

I am trying to get the height and width of a graphic in pixels. However, when I set the horizontal/vertical measurement units to pixels, I still get decimals for the geometricBounds coordinates (2.3, 500.2345234). Why is that? I would expect to get whole numbers.

• ###### 1. Re: Height and width of graphic in pixels

Why do you expect to get whole numbers?

InDesign does not snap to pixels...

Harbs

• ###### 2. Re: Height and width of graphic in pixels

Then that's what I need to know. Still seems a little strange to me (I am not a designer, but a programmer). How are half pixels represented when displayed on screen?

• ###### 3. Re: Height and width of graphic in pixels

Despite Adobe's efforts to convince the world of the contrary, "pixels" are not really an existing measurement unit. The "pixel" unit you are seeing is just InDesign that replaces "pt" with "px" in all dialogs.

Experiment #1: place an image of known pixel dimensions; for example, 128 x 64 pixels. Scale the screen to 100%. Is this image you see now 128 x 64 pixels? Measure by making a screen shot and opening it in Photoshop. (I grant you it's possible, but somehow I doubt it. InDesign does not know your screen size in pixels.)

Experiment #2: place an image of known pixel dimensions; for example, the same image as above. Now scale it horizontally and vertically by 99%. What size is this image, in pixels? Pick one:

(a) it's 128 x 64 pixels, because scaling has no effect on actual pixel content; only its effective resolution changed.

(b) it's 126.72 x 63.36 pixels, because that's what 99% of the dimensions calculate to.

(c) it's 127 x 63 pixels, because that's what it scales to, and your screen cannot display fractional pixels.

- - - -

All of this isn't really helping, isn't it. Try this: take your image dimensions in inches and multiply by the effective ppi of the image. That will give you a number of pixels.

• ###### 4. Re: Height and width of graphic in pixels
How are half pixels represented when displayed on screen?

The same as a line of 0.5 pt thick -- they are not. But you can zoom in and see that this line is half as thick as a 1 pt one. Presumably you can do the same with pixels.(*)

(*) Except in a program that actually manipulates real, existing pixels, such as Photoshop. You can't get half a pixel with that.

• ###### 5. Re: Height and width of graphic in pixels

```var myDoc = app.activeDocument;