Is is possible to get pixel to mm ration from image exif. I have focal length of camera, image resolution, as well as camera distance from object in image (outside exif).

I have distance from origin (X, Y) in meters, and I need to figure out how to use those coordinates in pixels in order to move image.

  • 1
    You would also need sensor size, leaving it as trigonometry problem.
    – Itai
    May 10, 2017 at 22:40
  • And also account for spherical aberrations/distortion in the lens. May 11, 2017 at 10:37

2 Answers 2


If you know the height or width of an object and it’s distance, you can trace out a triangle. The vertex is the center of lens. Example an object is 2 meter in height, 8 meters from the camera -- the length of the base of this triangle is 2 meters, the height of this triangle is 8 meters. Bisect the triangle and ½ the base is 1 meter. The ratio of base to height is 1 ÷ 8 = 0.125.

Inside the camera, the projected image of this object traces out a similar triangle. The vertex is at the center of the rear lens element. The height of this triangle is the focal length. Suppose the lens has a focal length of 75mm. The height of the image as projected on the sensor will be 2 X 75 X 0.125 = 9.375 X 2 = 18.75mm.

Technically the measurement points associated with the lens is the front and rear nodal points. You will not easily discover their locations. If the subject is a meter or so distant, you need not worry, such a small inaccuracy is moot. Likely if you use the rear element as the rear nodal your calculation will also be satisfactory. If not, refine the height of the in-camera triangle by trial and error to improve accuracy.

  • MIght be helpful to add a drawing of a lens w/ the chief and marginal (a and b) rays. May 11, 2017 at 11:29

There are EXIF tags for recording the resolution, but those are intended for scanners that have a known scanning resolution. A camera can have wildly different distances to the subject, so the resolution is essentially unknowable. The EXIF spec states "When the image resolution is unknown, 72 [dpi] is designated."

Calculating the resolution of an actual scene involves lots of variables: sensor size and resolution, distance to subject, lens focal length, lens distortions, focus breathing - and those are just the ones I can think of off the top of my head. If you really need to know, your best bet is to take a picture of something whose size is known and count how many pixels it takes in the final image. Then simply divide pixels/size.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.