Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Height and width of graphic in pixels

Community Beginner ,
Jan 18, 2011 Jan 18, 2011

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.

TOPICS
Scripting
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 18, 2011 Jan 18, 2011

Why do you expect to get whole numbers?

InDesign does not snap to pixels...

Harbs

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 18, 2011 Jan 18, 2011

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 18, 2011 Jan 18, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 18, 2011 Jan 18, 2011
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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 23, 2011 Jan 23, 2011
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines