Some cameras, with some lenses, will give the camera-subject distance in the Exif. If you haven't got the right combination then you can work it out if you know the lens focal length, the size of the subject in real life, the size of the subject in the image and the image size.
The Dimensional Field of View Calculator on
this page will make the calculations easier.