How do i calculate cm in pixels and vice versa? (e.g. having 300 or 72 dpi)

```
on cmToPixels(cm, dpi)
return ((cm as centimeters as inches as number) * dpi) as integer -- To nearest pixel.
end cmToPixels
on pixelsTocm(pixels, dpi)
return ((((pixels / dpi) as inches as centimeters as number) * 10) as integer) / 10 -- To nearest 0.1 cm.
end pixelsTocm
set dpi to 300
set cm to 10
cmToPixels(cm, dpi) --> 1181
pixelsTocm(result, dpi) --> 10.0
```

Edit: The handlers above use AppleScript’s quantity coercions. Obviously the action would be much faster with “precoerced” constants:

```
on cmToPixels(cm, dpi)
return (cm * 0.393700787402 * dpi) as integer -- To nearest pixel.
end cmToPixels
on pixelsTocm(pixels, dpi)
return (((pixels / dpi) * 25.4) as integer) / 10 -- To nearest 0.1 cm.
end pixelsTocm
set dpi to 300
set cm to 10
cmToPixels(cm, dpi) --> 1181
pixelsTocm(result, dpi) --> 10.0
```