简体   繁体   English

Pixel 2 CM转换Javascript

[英]Pixel 2 CM convert Javascript

i must convert px to cm with javascript 我必须使用javascript将px转换为cm

oneCM= 37.795276 is it true everytime? oneCM = 37.795276每次都是真的吗?

What is the DPI's role here? DPI在这里的作用是什么?

and if is variable CM on the monitor (factor DPI) how can we find DPI's 如果显示器上的CM为变量(DPI因子),我们如何找到DPI

Do you want DPI or PPI? 您要DPI还是PPI? - DPI is for printing, PPI for screens. -DPI用于打印,PPI用于屏幕。

If you are talking about the "real" size of an image or a webpage on your screen we're talking about PPI. 如果您正在谈论屏幕上图像或网页的“实际”尺寸,那么我们在谈论PPI。 Common PC screens have approx. 普通的PC屏幕大约有 80ppi, the macbook pro has 220ppi. 80ppi,macbook pro为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. 如果要转换这些尺寸,则必须首先将所需尺寸从cm转换为英寸,然后将其乘以所需的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. DPI用于打印也是如此。 You have to know the DPI of your printer (common printes have 72dpi, commercial printers have something between 150 - 600dpi). 您必须知道打印机的DPI(普通打印为72dpi,商用打印机的DPI在150-600dpi之间)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM