Pixel to MM equation?

tl;dr: If you don't know the DPI of the device, you won't be able to deduce how big the pixel is in the real-world.


Pixels on their own are not real-world units of measurement.

They can become a real-world measurement if you take into account the DPI value of the device that displays them.

The formula is:

  • mm = ( pixels * 25.4 ) / DPI

So 8 pixels viewed on a 96-DPI screen setting:

  • ( 8 * 25.4 ) / 96 = 2.116mm

All this assuming the device is not scaled/zoomed.


What i did :

 <div id="my_mm" style="height:100mm;display:none"></div>

Then:

var pxTomm = function(px){   
   return Math.floor(px/($('#my_mm').height()/100)); //JQuery returns sizes in PX
 };

Tags:

Jquery

Pixel