How to calculate
Divide image size by object size in the same units to get the magnitude of the magnification. Multiply object distance by that ratio to get image distance. Focal length equals object distance times image distance divided by their sum.
Worked example
Use Known lens measurements Object size and image size · Distance from object to lens 1.05 · Object distance unit Meters · Object size 1 · Object size unit Meters · Image size on sensor (mm) 50. The result is 50 mm.
Input and result notes
Use positive distances for a real object and a real image. Measure distances from the lens reference planes. A thick or internally focusing lens may require manufacturer data at close focus.
Stanford thin-lens image formation and conjugate distances