Pixel 2 CM convert Javascript

天大地大妈咪最大 提交于 2019-12-12 02:13:23

问题


i must convert px to cm with javascript

oneCM= 37.795276 is it true everytime?

What is the DPI's role here?

and if is variable CM on the monitor (factor DPI) how can we find DPI's


回答1:


Do you want DPI or PPI? - DPI is for printing, PPI for screens.

If you are talking about the "real" size of an image or a webpage on your screen we're talking about PPI. Common PC screens have approx. 80ppi, the macbook pro has 220ppi.

If you want to convert those, you first have to convert your wanted size from cm to inches and then multiply it with the wanted ppi.

1cm = 0.39inches
0.39inches * 80dpi = 31.5px

Vice versa:

900px / 80ppi = 11.25inches
11.25inches = 28.575cm

The same works with DPI for printing. You have to know the DPI of your printer (common printes have 72dpi, commercial printers have something between 150 - 600dpi).



来源:https://stackoverflow.com/questions/12800821/pixel-2-cm-convert-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!