Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Why do you expect to get whole numbers?
InDesign does not snap to pixels...
Harbs
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
You can get this info from link's metadata:
var myDoc = app.activeDocument;
var myLink = myDoc.allGraphics[0].itemLink;
var myLinkXmp = myLink.linkXmp;
var myLinkWidth = myLinkXmp.getProperty("http://ns.adobe.com/tiff/1.0/", "tiff:ImageWidth");
var myLinkLength = myLinkXmp.getProperty("http://ns.adobe.com/tiff/1.0/", "tiff:ImageLength");
alert("Pixel dimentions of the first link:\nWidth: " + myLinkWidth + " pixels\nHeight: " + myLinkLength + " pixels");
However, not all links contain it.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now