# How to calculate the required working distance for an object to fill the camera sensor?

I would like to take photographs of a flat object with the camera at some adjustable distance from this object. I would like the object to just fill the camera's sensor.

Given an object of extent $s$, with the camera focused on the center, a lens of focal length $f$, and a sensor of size $b$, what should be the working distance $D$ such that the object just fills the camera sensor? Is this enough information to answer the question, or do I additionally need to know other variables like how far the lens is from the camera sensor?

Edit:

I judged from "Multiple view geometry in computer vision" by Hartley that the relevant constraint, at least from a pinhole camera model, is sf = bD. Does this seem correct? Is this likely to hold approximately for a real lens?

• Check this answer and "convert" angles in linear: photo.stackexchange.com/a/5924/34947 Commented Jul 12, 2023 at 16:22
• Thanks Romeo - this helps. I am surprised though -- following this link I conclude again that D = sf/b. But I currently have a configuration set up with an object of size s=80mm with an f=105mm lens, an image sensor b=37mm, with the object fully resolved at a distance near 40cm, whereas this formula says it should be near 20cm away for the same result. Could this just be a result of the oversimplified pinhole model? Commented Jul 12, 2023 at 16:51
• @kevinkayaks where do you measure the distance from? Can you be more specific about your setup? 40cm sounds very wrong. The formula works quite well for my setup. Commented Jul 12, 2023 at 17:12
• sorry @Euri I need to get back in the lab to make the measurements and describe - may be a few days Commented Jul 13, 2023 at 18:07
• I know this will be calculable, using maths I wouldn't even begin to understand… but wouldn't it be quicker & easier to just move the camera or change the zoom until it fits? That's how every photographer since Louis Daguerre has done it ;) Commented Jul 13, 2023 at 18:39

This online field of view calculator will calculate the answer(s) you are looking for. I can't comment on the math involved, but the site does discuss approximations and lens types, too.

FL=(subject Distance/subject Size)Sensor axis, or FL=(D/S)Sa

For example, say you want to fill the frame width on an APS body (24mm sensor width), taking a picture of a squirrel that is about .5m long (including its' tail), from about 10m distance:

FL=(10/.5)24 = a 480mm lens is required. But you probably don't want to actually fill the frame edge-to-edge, so a 400mm would probably be ideal.

Or maybe you are going on Safari to photograph big cats, which are about 2m long. You've been told you can expect to get to within about 30m, and you are bringing a FF camera... what lens do you rent? FL= (30/2)36 = 540mm... it looks like a 500mm f/4 would be a great choice.

If you were concerned with subject height in a landscape (e.g. a giraffe); then you would want to use the short sensor aspect for the calculation (24mm instead of 36mm for a FF sensor).

Of course, the formula FL=(D/S)Sa can be rearranged to solve for other variables as well:

• D=(FL/Sa)S; determines how close you have to get
• S=(FL/Sa)D; determines how big the subject can be
• Sa=(D/S)FL; determines the crop factor (sensor size/edit) required
• The placement of the squirrel's length in metres confused me for a second. I thought it meant that the squirrel was 1.5 ft long, and it's tail was 0.5m long! Also the unit designator for metres is "m" and not "M" (In SI units M stands for mega) Commented Jul 13, 2023 at 12:43
• @PeterM, thanks... I'll clean it up. Commented Jul 13, 2023 at 13:26

Imagine your camera lens as having only one glass element. Now draw an imaginary triangle from the boundaries of the image sensor to the center of this lens. You have traced out an image triangle. If the camera sports an APS-C format, the base of this triangle is the same as the horizontal dimension of the imaging chip. In other words, 24mm. The height of this triangle is the focal length, let’s set it at 30mm.

The ratio of the height to base of this triangle is 30 ÷ 24 = 1.25.

You can now draw another triangle, call it the object triangle. Its apex is the center of lens. The apex of the image triangle and the apex of the image triangle are identical as to their angle (same degree of angle). In other words, these triangles are similar in shape, all angles being the same. If we know the dimensions of an object we are about to image, we can compute the subject distance needed to just fit the boundaries of the sensor.

Suppose the object is a candy bar 200mm long. Set the length of the base of the object triangle to this value, 200mm. Now the height of this object triangle is easily computed as its ratio is also 1.25.

Thus, the camera to subject distance is 200 X 1.25 = 250mm. This is just an approximation (A good one).

Why is it not spot on? A modern camera lens is somewhat complex. It is constructed using several glass elements, each different as to their power. This makes determining the measuring points complicated. We measure object distance from a point called the front nodal. We don’t know where this point is actually located. As you work this problem and compose, you can refine your guess as to its location.

You will solve this problem using a ratio you compute after putting in your actual values as to sensor width and focal length.