I can get PPI for a JPEG image using the following command:
$ identify -format \"%w x %h %x x %y\" mypic.jpg 1600 x 1200 72 PixelsPerInch x 72 PixelsPerInch
1 inch =~ 2.54 cm. So it is trivial to convert between the two.