A Ruby function that can be easily adapted to work with any language, because it uses a simple division and multiplication to calculate the number of centimeters in the given pixel size.
def PixelsToCentimeters(Pixels, DPI)
return (Pixels / DPI) * 2.54
end