hi! does anyone knows how to convert metric units (such as centimeters) to pixels by hand (i mean the normal calculation, not a function from a programming language or something) ? i just want to be accurate and use pixels instead in measurement...=/ i tried searching but it gives me confusing prolan functions...xD

Dani AI

Generated

A short clarification and practical method that directly answers the original question while tying together the earlier points from , , and .

For print (definite target): pick the target device DPI (printer or raster output) and convert metric to pixels using that DPI. Example workflow: decide on DPI (300 is common for photo print), convert centimetres to inches, then multiply by DPI. A small utility formula and a one-line JS helper:

pixels = round( (cm / 2.54) * DPI )

// JS helper
function cmToPx(cm, dpi){ return Math.round((cm / 2.54) * dpi); }

For screens (variable target): this is why the thread got confusing — screen pixels are not a fixed physical size. Two useful ways to get a screen's pixels-per-inch (PPI):

  1. From diagonal size and resolution:

    PPI = sqrt(width_px^2 + height_px^2) / diagonal_inches
    pixels_for_cm = (PPI / 2.54) * cm
  2. By measuring: display a known pixel-width element, measure its physical width with a ruler, then compute pixels per cm directly (pixels / measured_cm). This captures browser/CSS mappings and devicePixelRatio issues.

Notes and troubleshooting

  • Historical claims like "72 px per inch" reflect legacy conventions; modern web/CSS behavior often treats 1in as 96 CSS px, and high-density displays use window.devicePixelRatio to map device pixels. That mismatch is the root of the confusion raised by and .
  • For print work, always use the printer's DPI. For UI/web design, prefer CSS/layout units (px, rem, %, responsive breakpoints) and test on real devices rather than relying on a single cm->px conversion.
  • Quick checks: use a browser ruler extension or a tiny test page with a width: Xcm element and inspect its pixel width with DevTools to see how the browser maps physical units on that device.

Recommended Answers

All 5 Replies

Can you convert inches to pixels?

1 inch = 2.54 cm.

hi! does anyone knows how to convert metric units to pixels?

It depends on how many dots per inch you use (DPI) If you know this, you know how many pixels per inch and then just use midimagics tip

Niek

^i already did before, but it's too complicated..

hi guys thanks for the ideas...i found it how! ^^ it's 72pixel (up to 120 pixel) = 1 inch (depends on a the monitor)..it's on a book...that's maybe why i can't it find it on the web..=/

But that depends on what monitor resolution someone is using.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.