October 16, 2001 - Pixels to Inches Conversion
October 16, 2001|
Pixels to Inches Conversion
Tips: October 2001
Yehuda Shiran, Ph.D.
styleobject's pixel-based properties. One way to go about it is to set the location of an invisible marker in inches and then query its value in a script, yielding the same value in pixels. Let's see an example.
IMG tag defines an invisible marker, one inch away from the left edge of the window, and one inch below the top edge of the window:
Click here to print the offset of
<IMG ID="ratiomarker" CLASS="mmarker" STYLE="visibility:hidden; left:1in; top:1in; position: absolute" SRC="marker.gif" WIDTH="15" HEIGHT="15" BORDER="0">
ratiomarker. Since the invisible marker's offset is one inch in the
IMGtag, the returned value
offsetLeftis the conversion factor, pixels per inch. Also, notice that the marker style must be defined with absolute positioning.