So a little more info, I looking for an automatic way of doing this, so that I can improve the Spike photogrammetic camera product.
We are prototyping a special Jpeg output from the Spike.
The Jpeg will be deskewed, eg the measurement surface, which is usually oblique to the camera, will be flattened.
Then we compute a resolution in DPI for the measurement surface, and apply this to the JPEG EXIF resolution fields.
The idea, is that a CAD package imports the JPEG, reads the resolutions and presents the image with the correct physical measurements.
This is intended to be a standard output, so for example, users can photograph the side of a building, put it into the CAD, and measure directly.
Ive tested the concept in CorelDraw, which our Signage customer base use, and it works really well, it reads JPEG resolutions, get the image to the right size and makes downstream design work a lot simpler.