# Calculate Distance or Sizeof an Object in a photo image

This is rather specialized, but people do ask how to determine or measure the distance or size of an object or subject in a photo image. It is simple math, but it will ABSOLUTELY require knowing accurate sensor size (both the pixel and mm dimensions) and focal length of your camera, which are all important to calculations, but which can be very difficult to determine for automatic cameras, especially cell phones and compacts. A consumer camera is really not designed to be a precision measuring instrument. A strong warning about this calculator is necessary: Acquiring the necessary accurate input data for small cameras likely may be difficult, if even possible.

### The calculator is below, but there’s lots to get out of the way first

Any meaningful accuracy needs you to be pretty confident that you do in fact actually know your cameras actual sensor size and focal length. Best case for this, you will have a larger camera, like DSLR size, which typically do actually specify this data. But this is NOT an easy question about small cameras, at best difficult and requiring a bit of technical understanding. Before bothering to start calculation here (especially Compact and phone camera users, which is the least likely success, due to difficulty of finding accurate camera specifications.) Please read the Help material below, plus the section following immediately next, for help determining the camera's sensor size and focal length values. It will tell you all I could repeat in email. If your results don't seem reasonable, distrust and verify all of your inputs (including sensor size, focal length, crop factor, aspect ratio, and scene distance). Camera specifications, if even specified, are rounded approximations.

I am trying to discourage attempts expecting that guessed or unknown inputs will produce meaningful accuracy. The data specifications that we think we discovered are often incorrect, again which is more likely true of phone and compact cameras than larger ones. The math is correct, but you MUST have reasonable confidence and knowledge that your input data is in fact accurate data, or else you're wasting your time here. Calculations absolutely require accurate data. Otherwise, garbage in, garbage out.

First, three very common mistakes to avoid:

• Your camera DOES NOT EVER USE Equivalent Focal Length, so never specify that it was used. Only specify the real focal length of your actual cameras lens. Even if you see a few internet sites reporting your cell phone focal length to be around 26 to 28 mm, that is the Equivalent focal length, and IT IS WRONG for the real focal length of your phones actual lens. The real focal length of the normal lens of a cell phone camera is in the neighborhood of about 4 mm (or plus a fraction, but it depends on sensor size). However some online sites reporting cell phone specifications do report Equivalent focal length instead of the actual focal length.

The concept of Equivalent focal length number is that it is instead only used by a hypothetical 35 mm film camera for it to then show the same field of view as your camera sees. This might be informative if you are familiar with using 35 mm cameras. If you knew what field of view that the equivalent lens showed on that camera, then you know what to expect your lens will also do on your camera, if you don't already. But if not familiar with the lens on a 35 mm film camera, then knowing this is of no use to you,

• Zoom lenses only specify focal length at either zoom end. If used when zoomed to some intermediate point, the actual focal length used is not known accurately.
• We typically just guess at subject distance, I'm thinking likely often not within even 20%. The reported Focus Distance in the image Exif data is Often NOT very accurate (try a measured test to verify it at your same zoom focal length and a similar focus distance). For evidence to make this point, see this chart about measured distances vs what some high end lenses report for focus distance. That article is about balanced flash problems trying to use the lens distance to control TTL direct flash exposure, but it applies here too for the same accuracy reason. If using the reported distance, it needs to be measured and verified at the same zoom and focus distance you will be using. The lens distance possibly might be about correct sometimes, but it sure seems Not the way to bet. An older prime lens (non-zoom) has the best chance, but zoom lenses and internal focusing lenses are the worst about reporting accurate focus distance (because then geometry inside the lens changes with zoom and focus).
There are plenty of issues when trying to determine the sensor size of compact or phone cameras. Also with mixed formats (both video and still photo images from the same camera). For the various calculators here, these Issues of determining camera sensor size are summarized on one place. Please see that if any issues with sensor size.

If you don't know your compact or phone sensors accurate W×H mm dimensions, but you can find the Equivalent focal length (compacts and iPhone typically supply this, in specs or maybe in the image Exif, see the help link here), then consider either of Sensor Size Option 2 or 3 below to compute your sensor size (and specify the correct Aspect Ratio). It can compute your accurate sensor size, and it may be the only manufacturers specification you can ever find for compacts and phones.

But make no mistake, Equivalent focal length is NEVER to be used as your cameras real focal length (because it is NOT). Equivalent focal length is the focal length used on another camera, specifically a hypothetical 35 mm film camera (which is of known size and is the standard reference of comparison), which will produce equivalent Field of View size on THAT 35 mm film camera. 35 mm film size is just a standard comparison for digital cameras, since many users have years of 35 mm film experience, and this comparison tells them what to expect this digital camera does. The Field of View is what is equivalent on the two cameras. Equivalent focal length is only mentioned here because it is that comparison ratio, from which if known accurately, your camera’s real sensor size can be computed. That’s the only purpose here. But to specify focal length, use only your own cameras real focal length, NEVER specify any Equivalent Focal Length of another camera.

The most common blunder when using this calculator is to specify Equivalent Focal Length as your camera's real focal length. Some web sites repeating phone specifications show an Equivalent focal length number instead of the real actual focal length the phone actually uses. But that Equivalent focal length is Not even about your camera, it is simply a comparison to another lens that is instead used on another hypothetical 35 mm film camera (for it to then see the same Field of View that your camera sees). A normal cell phone focal length is typically somewhere around 4 mm, and is NOT any 26 or 28 mm number you might see online somewhere. Beginners apparently hear the Equivalent term and often get the very wrong idea that their lens somehow magically changes to be the Equivalent focal length, but that is impossible, it cannot magically change. This is a common error, so please DO NOT USE EQUIVALENT FOCAL LENGTH as your camera's focal length, as that would be meaningless. Your lens has its own actual real focal length (marked on the lens, or in its specs).

However, from the lens spec, the 35 mm Equivalent focal length / Your Camera's actual focal length is the Crop Factor of your sensor size. These are just comparisons to 35 mm film size. Crop factor describes your sensor size, and it means that the diagonal dimension of 35 mm film (and also the diagonal of the 35 mm field of view, when and if both cameras are using the same lens focal length) are this multiple of your Crop Factor larger than your camera. Users with years of experience with 35 mm film find it useful to know in those familiar terms what the field of view of this digital sensor will now show. But Equivalent Focal Length is not about your own camera, because it obviously must use its own lens instead. However, Crop Factor does compare the sensor sizes directly. And since we know all about the size of 35 mm film, we can then use this Equivalent focal length to get Crop Factor to determine the size of the sensor on your camera, for use with this calculator.

The calculator can compute the sensor size in Option 2 and 3. All you have to do for Option 3 is to enter the specification for the Equivalent Focal Length, and its corresponding focal length of your lens. If a zoom lens, you need to understand that the focal length specifications are the zoom end points, which is probably Not the zoomed focal length your picture just used. I'll repeat this more in the Notes below.

## Using this calculator

Restrictions: You need the original digital image file from the camera. It won't work from a cropped image or a paper print. It won't work correctly for close or macro distances or for fish eye lenses. The focal length marked on the lens is for infinity distance, and it changes at closer distances, so I suggest staying at least about six feet or two meters distance (camera to object), and farther is better.

The main problem is it can't work correctly for incorrect guesses about sensor size or focal length or subject distances. And the object should be at level elevation from camera, and not be tilted or rotated away from the frontal camera view (which then shows foreshortened size). The calculator works measured in either height or width of the sensor, but not if the object is angled away from the camera.

Distance: A longer story, but normally the focus distance is measured to the film or sensor plane at the back of the camera. However the calculator math instead must use the distance to the lens H node that is the apex of the external field of view angle (Thin Lens model at end below). That node is often inside the camera lens somewhere, or somewhat in front of longer lenses (like 100 mm focal length or more). If the object distance is several feet away, then a few inches difference to this node does not seem important. It would matter if pretty close, but then the focal length is probably wrong anyway. This node is up around the lens somewhere, but we aren't told just where. So see notes at end of this page about how to find that node.

This calculator can find approximate distance or size of an object in a photo, but the calculator must be accurately told the following things about the situation. I am trying to be discouraging about this or any other similar camera calculation, unless you feel technically capable of actually knowing your input data values are actually correct. The math is simple and correct, but the problems are from wrong input data. And the consumer camera is not really the best tool for any precision measurements.

You measure the visual size of an object in the image by determining the number of pixels it covers. If it covers 1/4 of the pixels, then it covers 1/4 of the sensor mm. This is easy to do when the photo editors tell you the size of the crop box that you mark. If not, you can actually crop it (tightly around the object) and then look at the cropped image dimensions then (but DO NOT SAVE that edit if you still wish to retain the full original image. Or work with a copy of the file.)

You specify if you are measuring width or height direction, and also how the camera is rotated to determine which dimension is that width or height. Don’t get confused, when the calculator says width or height, it means the literal vertical or horizontal direction you specify.

Describe the camera and situation:

1. The physical sensor size, Width and Height in mm. Simpler cameras don’t see any need to tell us this, but some do offer hints of approximations in a 1/xx inch size, or sensor size can be computed from accurate Equivalent Focal Length specs. (We know the full frame 35 mm film frame is 36x24 mm. Different aspect ratios must be considered, but see Calculator 4 here.) See the Help above.
2. The Sensor image size, Width and Height in pixels. A cropped image cannot be used, the image pixels must match the full mm dimensions and the full pixel dimensions of the sensor (an image “straight out of the camera”, else serious inaccuracy). Some cases also ask aspect ratio of the sensor and image.

And then, specify three of these next four, to compute the other one:

3. Lens Focal Length can be computed if you can actually specify the other three (it's all the same math, just rearranged by algebra, so it is added here). It is the focal length that the image used, in mm. The Focal length marked on the lens is specified at Infinity, and it changes at shorter distances, especially close distances.

But if specifying focal length, NEVER use an Equivalent Focal Length. Only use the actual real focal length of your lens. The focal length marked on the lens is a rounded specification for the infinity focus position. Focal length will vary longer with a closer focus distance (or shorter on some Nikon internal focusing macro lenses). Also a zoom lens has many focal lengths (the image Exif data should show a crude guess). This camera number is not as precise as you might imagine, especially for zoom lenses.

4. The distance to that object from camera, in same units as size. Wild guesses are not very accurate, but it can be computed from the other three values. And note that the focus distance reported by camera Exif is often not accurate either, especially not in zoom lenses, or lenses with internal focusing. The calculator actually computes the full field of view dimension (that fills the sensor at that distance), and then the image object size in pixels computes the object size.
5. The real life size of the Object, the actual or at least a reasonable approximate estimated Width or Height size dimension, in feet or meters. Not necessarily the "focused subject", but some known object out there. The result will only be as accurate as this estimate. Horizontally skewed or vertically tilted angles will be seen foreshortened, and if not seen at 90 degrees to camera, the real dimension is greater than apparently seen at that angle.
6. The image object size (pixels) of the actual Object in the image. Can be width or height. A resampled image is a special problem, it should be a 100% full sensor size image, as at viewed full size. Again, some photo editors (at least Adobe) will show the pixel size of a crop box as you draw it around the object. Otherwise, you can actually crop the image to object size, and the new image object size will be dimensioned in pixels. But DO NOT SAVE that cropped image, cancel out of any save to retain your original image.

The calculator will compute one of # 3, 4, 5 or 6 from three of the other values.

Just cycling through the four top buttons will recompute, but will not change anything if all the values are already there. They are a computed set. But if one value is unknown, you have to find it first. The calculator requires three values and can find the fourth.

UNITS: Focal length and sensor size are always in mm. Otherwise, the dimensional units outside the lens specify feet or meters, and are suggested, but you can use any external units (including meters or miles or km or cubits, etc). Results will be in those same units, but you must be consistent. If you understand how, you can enter exponential nomenclature (for example 1.5E3 is 1500). But DO BE CONSISTENT. External distance and real size must be in the SAME units (because the dimensional units in the similar triangle in front of the lens cancel out if consistent).

The reason results may not be precisely accurate is that camera specifications round the values of Focal length, Sensor size in mm, and Crop Factor. The calculator uses those rounded values to compute ratio numbers, and then any input errors are magnified in the external field dimension results. It can be close enough, but cameras are Not precise measuring instruments.

Cameras with interchangeable lenses (including DSLR) specify focal length (rounded, and to large extent is just nominal) and actual sensor size W×H in mm, but these tiny values (including their errors) get hugely magnified in the external field dimensions. You should not imagine magical precision from the camera numbers. I wrote the calculator thinking of DSLR camera numbers, and it is just simple geometry, and it works well (if we actually know the accurate input numbers). But compact cameras and especially cell phones don't tell us much about the camera. What we are told about the small cameras can be a bit crude. Not knowing the accurate input data can be a HUGE problem for calculations. You must know the data.

## Calculate Distance or Size of an Object in an Image

 First select the options to be used: Find Distance to object (feet or meters) Find Size of object (same units as distance) Find image Size of object (pixels) Find Focal Length (mm) Sensor image size × pixels Largest sensor mm is now Horizontal Rotated, Largest mm is now Vertical Regardless of any camera rotation, you are measuring Horizontally or Vertically Select 1 of the 3 Sensor Size options: 1 Sensor Size   × mm 2 Crop factor    Aspect Ratio  3:2 (DSLR) 4:3 compact or phone 16:9 in 3:2 camera 16:9 in 4:3 camera 16:9 camcorder 3:2 in 16:9 camcorder 4:3 in 16:9 camcorder 5:4 4x5 camera 3 Equivalent Your Lens Focal Lengths   mm mm Aspect Ratio   3:2 (DSLR) 4:3 compact or phone 16:9 in 3:2 camera 16:9 in 4:3 camera 16:9 camcorder 3:2 in 16:9 camcorder 4:3 in 16:9 camcorder 5:4 4x5 camera Enter all below except the menu choice to find Lens Focal Length Used mm Object H in image pixels H of real Object feet or meters Distance to Object feet or meters

Any angle: °
is Multiplier:

Numbers only. A NaN result will mean an input is Not A Number. Decimal points are OK.

You must be consistent for all instances, but can use either feet or meters for dimensional units (distance, size), and the results will be in those same units. Sensor size and focal length are in mm.

The options will compute and change the appropriate field, where the Pink background will appear. Any value already in the field you are finding will be ignored and replaced (by computing with all of the other fields). So when it has already computed once, clicking Compute again (or selecting another computing goal) without change can only compute the same matches, with no visible change then, until you change something.

Did I mention NEVER USE EQUIVALENT FOCAL LENGTH in the field that says "Lens Focal Length Used:". Use the actual numbers for Your actual lens and sensor.

A red error message fussing about Image and Sensor Aspect Ratios is hopefully diagnosing input typo errors on the sizes. Otherwise, it suggests the image has been cropped to a different size than the sensor. The programs comparison tolerance (for these aspect ratio differences) is 1%, which is about double any expected rounding variations, and hopefully is not too restrictive for normal situations. It still computes then, using pixels to compute object size percentage on the sensor, and then computes all the geometry with the mm size of the sensor. They do need to be the same thing.

Width and Height: Here, width and height means horizontal or vertical in the normally oriented photo image, regardless of how the camera sensor is rotated. Just saying, if the image long image dimension is vertical, that is still "height". Repeating, for the object in the photo image, the calculator asks if you are measuring Horizontally or Vertically in the normally oriented photo image (where Height always runs vertically in the photo image, regardless if that is the long or short image dimension). We normally think of “Sensor Width” as the larger number of mm and pixels, but if camera is rotated up on end, the larger number will become vertical “Image Height”. Either way, object height is always Vertical as the image is correctly viewed. It should be as expected, but to be very clear, the orientation and use of the sensor dimensions will be shown, so you can verify it is specified correctly.

Foreshortening due to skewed angular differences:  This is a difficult problem, try to avoid it by keeping the camera pointed straight and level to the dimension being measured, NOT skewed up and down if measuring height, and NOT skewed sideways if measuring width. Keep the camera on-center and NOT slanted to the object. And the object itself should not be skewed to the camera either. Skewed angles less than 10 degrees are not so serious, but the idea is the camera should be 90 degrees to the object surface you want to measure. The calculator does Not compute foreshortening of the object due to angle. The skew angle to the object might be actual vertical or horizontal camera angle, or it might just be the rotation of the object itself from actual vertical or horizontal (and the worst case is both angles). This paragraph words it as a vertical difference, but exact same is true of horizontal differences too (substitute either word). The camera is assumed level vertically. Then if both the camera back (sensor plane) and the object itself are both vertical, then these are parallel at any object position, so there is no tilting (no walls falling backwards), but larger angles from center can still cause foreshortening of vertical dimensions. Or if the camera is aimed up or down is the same effect (plus or minus angles are the same effect). The angle causes the object pixels to optically measure shorter than it actually is. The correct multiplier computes the actual height dimension. This chart of angles can be a foreshortening guide, which is the angle of the object from the camera (0 degrees is level vertically, or straight ahead forward horizontally). Chart Usage is:

Actual Height = Apparent measured Height × Multiplier.
Apparent height = Actual Height / Multiplier.

Photography Tip at tilted angles:   If you think to look first, you can see if indoor walls or buildings are skewed and leaning to and fro in the viewfinder. This is easy, you can simply Level the camera aim until you see them straighten in the viewfinder. You merely have to think to look and actually SEE it the viewfinder image. Tall vertical objects will still be foreshortened with angle, but will not tilt back if the camera is level (when the camera back is vertical and perpendicular to the horizontal). To prevent tilted verticals, hold the camera level (which could require turning the camera up on end for greater visual height range). When I say Level, that assumes the object is straight up and down, like a skyscraper building is straight up and down, so you prevent making it look tilted back by keeping the camera level (and you will have to move way far back from it to include the view of its top). But the exception is if the object itself is actually leaning back (like a picture frame leaned back on the couch), then you have to get the camera higher, so it can be aimed directly straight into the objects surface.

Angles are NOT linear changes. If about field of view, using twice the distance or half the focal length doubles the Field of View dimension (dimensions in feet or meters are linear), but the degrees of the new angle is more than double (trigonometry of angle degrees is not linear, each degree from center covers a progressively larger distance span). The foreshortening multiplier also becomes larger with every degree. Except “Small Angles” (defined as less than 10 degrees) can be considered linear. Larger angles are very significantly nonlinear. Don't forget to account for your camera height above ground level.

The sensor size Option 3 is intended to make sensor size be easy for phones and compacts. Some phone cameras (iPhones do, but I think Androids may not) show the Equivalent Focal Length in Exif. Most compact cameras, for example, if the lens specification for your compact is 4.3 mm, and it is said to match the field of view with an Equivalent 35 mm film camera using the 24 mm lens, these are the numbers it wants (the Equivalent 24, and Your Lens 4.3 mm) from your lens specification, as shown in the examples. This procedure only computes sensor size, which is extremely important to calculations. It comes from the spec, and is Not the compact zoom focal length you think you used. If perhaps a compact, your picture may have used one of those end point focal lengths, or used another intermediate one, like 10 mm focal length, and that's the number that the scene description wants (to compute the picture). You must also specify the appropriate Aspect Ratio (normally 4:3 for phones and compacts).

Accuracy: The math is accurate, but the input data is more suspect. You might notice that simply switching to a rotated camera or measurement can change the computed distance slightly (30.07 to 30.12 in the initial default provided). This is simply because of rounding errors in the data. The aspect ratio in pixels (7360/4912 pixels = 1.4984:1) is not exactly the same ratio as aspect ratio of the sensor mm (35.9/24 mm = 1.4958:1). Yet both are camera specifications, and both round to 1.5:1.

The calculator necessarily does ask for several vaguely known things. If you know them all, more than vaguely, it can work, but that can be difficult. Bad results can come from several causes, all involving imprecise input data. Lots of chances to go wrong.

• Sensor size is very difficult to determine in smaller cameras, especially cell phone cameras. It is rounded numbers in any camera specification, surely within one mm if from actual specifications, but any errors are magnified by the magnification to the total field of view size. Larger cameras, like DSLR size, should be pretty close and well specified. The sensor size numbers of type like 1/2.3 inches are especially suspect, inexact, not even an actual dimension. It needs more than that, the actual real numbers.
• Focal length is harder than might be imagined. It is rounded too, within a few mm, but the marked focal length is valid for an Infinity focus distance. Then the focal length extends longer with closer focus, becoming most significant at close distances like only one or two meters. The extension should be minimal if focus is at a least a couple of meters though. Zoom lenses of course have many unmarked focal lengths, but if at one end or the other of the zoom range, it should be more accurately known. Focal length changes with zoom, and changes with closer distances, and also can change with any focus in internal focusing lenses. Any Equivalent Focal Length is of course wrong for this. An old prime lens is likely the most accurately known. Why that is used, I dunno.

Another variable is while zoom lenses focus continually, they report intermediate zoom focal length numbers in several relatively coarse steps (not continuously), which can lose precision then, with the reported value possibly not quite matching the actual number. Very adequate for its design purpose, but it can't be continuous. This is absolutely not an issue for photography, as we judge the viewfinder view without concern about the actual number. However if you're going to compute with it, the real number is useful. The point is, using either end of the zoom range are likely better known values, still rounded, but could be a bit more precise.

• Object distance should be better than a wild guess. And close distances (less than a couple of meters), can affect the measured distance number because the calculator measures distance to the H node, usually inside the lens somewhere, but longer lenses (say 90 mm or more, but possibly even less) place the H node outside in front of the lens. That node outside might still be very close to the lens, or might be further, perhaps comparable to the focal length in front. See "Finding that node" at the bottom of this page. Several inches seem an insignificant issue at distant focus though.
• Real size of the object could just be another guess too.
• The pixels of our camera images are exactly known though, and the measured pixels of the object ought to be pretty close too.

But our cameras were really not intended to be precise distance measuring instruments.

Published camera specs are typically nominal approximate values, or at best rounded values (including focal length, sensor size, aspect ratio, crop factor, equivalent focal length, and especially distance reported in Exif by lenses). The camera obviously does achieve its camera purpose, but it simply is NOT a precision measuring instrument. If you do need known precision measuring, you should get a different instrument intended for the purpose, so there can be some variances. The better you know your actual numbers, the better it will be.

Example: The calculator initial defaults match this photo example. The tape on the floor in the image measures 30 feet, which is the correct result to compare. If any doubts, you can repeat a similar test.

However, the camera Exif data says this Focus distance was 3.76 meters, which is 12.33 feet (but is 30 feet when actually measured), so don't trust that number (especially not in zoom or internal focusing lenses. This was a fixed 60 mm lens, but with internal focusing which can also change internal things.) This focus point was on the door knob, center of the frame. Cameras don't know distance, the lens reports its estimate based on how much its focus ring is rotated (which also reads in steps, not continuous)). But with zoom and internal focus changing everything internally, sometimes calibration must be hopeless, and the cameras distance report can be a real crap shoot (often worse than useless). To rely on the distance in the Exif is a probable mistake, and at least you should first actually verify the accuracy of your lens, at various measured distances, and at both wide and telephoto zoom (see more details of my complaining about this. I can ignore that the Exif focus distance number is often inaccurate in zoom lenses, but my complaint is that the camera metering system can actually use that number to override correct TTL BL direct flash exposure, sometimes instead seriously messing it up). Bottom line, do not trust the Exif focus distance number unless you have tested it at the similar zoom and distance.

This door measures 80 inches tall, or 6.67 feet (the size of some things might be reasonably estimated, which then won't be a precise number). In the original full size image, the cropped door is 2724 pixels tall (crop it, then look at the cropped image object size). Many image editors show the size of the crop box as you mark it, which is sufficient.

Nikon D800 DSLR camera: Sensor 35.9 x 24 mm. 7360x4912 pixels. Nikon 60 mm f/2.8 D lens. Computing distance using sensor Option 1, the calculator input specified 24 mm sensor height, 60 mm lens, 4912 pixel sensor height, 2724 pixel object height, and 6.67 feet estimated real object height.

The tape on the floor measures 30 feet, and the calculator computes 30.07 feet (which is within 0.2%). That 0.07 foot is 0.8 inches, which might be my error, because that distance is computed to the standard Thin Lens node somewhere inside the lens, not really known exactly where it is (but the calculated value is to it, and Not to the focal plane mark at rear of camera). I measured guessing the node was near the middle of lens, which could be an inch error (maybe a few inches in longer lenses). Still, the accuracy seems very adequate (at distance ranges of at least several feet).

Focal lengths are rounded, and in the Exif it says 59.9 mm, which calculates instead 30.02 feet (60.0 mm calculates 30.07, if door precision is entered as 6.67). But the distance is reasonably far, and it is not a zoom lens, so we can imagine it is a reasonable approximation.

I am at fault by speaking of this one result as if it is fully meaningful. The math is easy, but maybe it was a lucky result, and maybe NOT a typical camera result. Because, focal lengths may not be precisely as presented, sensor sizes can be hard to know precisely (especially for small cameras or video), and we tend to guess at all distances and sizes. Things that helped were a prime lens, a DSLR that actually specified sensor size, and an actual tape measure to verify distance and door size. Do not expect camera results to normally be this accurate. This example may verify the math, but cameras have many variables, often not known well enough. And users make errors determining the data too. Think of this camera method as only a rough approximation of distance or size. The only camera specs we need to know are focal length and sensor size, but it seems a lot to ask of simple cameras.

## Resampled Images

The image used cannot be a cropped image because we lose the correspondence with sensor size in mm. It cannot be printed, because we lose the object size in pixels. You might imagine some tries at this, but that's just more complication, and I'd suggest it really should be the original image file from the camera.

But for example, the small resampled image copy which is shown above on this web page is 450x300 pixels, and it can actually work too (only if the image is specifically still full frame view, NOT cropped at all). A cropped image cannot work, but a full frame a resampled image might work. The resampled size becomes the new "frame size in pixels", but the sensor size in mm remains the same. Then (in this resampled smaller image) the cropped door is 168 pixels tall, full image height is 300 pixels tall (still representing 24 mm in camera), and calculator says 29.76 feet (0.8%). Less precision in a smaller image or object due to less possible cropping accuracy, even one pixel is a bigger deal then. Still, even this is very near the measured 30 feet.

This 168/300 pixels or 2724/4912 pixels is simply computing the size as 56% of the 24 mm height of the camera sensor. Then knowing 56% of the camera sensor height in mm, and also the real life height, and the focal length distance in camera, it calculates distance to the subject. Such efforts do need to be sure that there was no cropping.

## Notes, Especially about Compact or Phone Cameras

Calculators simply MUST be told accurate focal length and sensor size numbers. Garbage in, garbage out. And that means YOU have to know those numbers. And that can be difficult in some cases.

Cameras with interchangeable lenses generally specify all the lens and sensor numbers (or Crop Factor), accurately, even if rounded a bit. But Compact and especially cell phone cameras often don't bother to tell us much. So if using a compact or smart phone camera, or a camcorder, you may not know the necessary numbers for this calculator. Here are some hints about a method that will help determine some usable numbers.

Focal Length: The marked focal length is a rounded number, and that marked focal length applies to focus at infinity distance, and will be a little longer than marked when focused up closer (and about double at 1:1 macro work). So at least a meter or two distance is necessary for the calculator here. If it's a still photo image (not a movie image), the focal length should be shown in the Exif data, which you can see there. Video images don't do Exif, because videos files often include many different camera shots. But for still images, the image Exif data normally shows lens focal length, for compacts and cell phones too (and is likely about all you will ever know about the cell phone lens).

Zoom: If the lens zooms, a complication is that actual focal length will be reported in relatively coarse steps (actual may be between steps). Zoom lenses normally specify their minimum and maximum zoom focal length, but we don't know any other value. These compact cameras do reset to one default focal length when turned on, but which we really don't know that value either. For measurements, your best bet then is to take the picture using only either the most Minimum or most Maximum zoom, since those two end values are reported better in the compact camera lens specification (rounded, but better). But that is speaking of Optical zoom performed by the lens. Any digital zoom is just a resample done by a computer chip (frame size remains the same, but the object in the frame changes size, which totally screws up our effort here). Digital zoom is likely unknown, and that try should be aborted.

Equivalent Focal Length: Compact and iPhone cameras typically report Effective Focal Length in the image Exif data. Which is NOT this cameras focal length, but this calculator can compute the sensor size from it. Not in all cameras, and not all Exif viewers show much, or may not be up to date with modern cameras. In this regard, see my notes about Exif.

Example for the iPhone: The iPhone XR does not specify a 1/xx inch sensor number, but its image Exif reports these next two corresponding values (but which are Not adjacent to each other in the Exif there, you have to hunt a little for each of them):

Focal Length : 4.3 mm (this is this camera's real number for focal length, found in the Exif)

Focal Length In 35mm Format : 26 mm (Equivalent Focal Length)

This cameras focal length says 4.3 mm, NOT the 26 mm which it says is for 35 mm cameras (for them to show the same Field of View as this camera with its lens, which is a standard comparison for digital cameras). These numbers are the iPhone XR, other models can vary a bit. Not all phones show this Equivalent Focal Length in the Exif data, but iPhones do seem to, and many compacts seem to, and lenses for larger cameras probably do.

From this ratio of 26 / 4.3, the calculators compute Crop Factor 6.0465, and sensor dimensions of 5.72 × 4.29 mm (for Aspect Ratio 4:3). These numbers are reasonably ballpark for many phones and compacts with similar crop factors, 5.5x to 6x. Finding sensor size can be pretty easy this way. Then the calculators will easily do this for you if you can supply your numbers to use. Since this lens does not zoom, then it’s the one actual real focal length used.

Otherwise, if Equivalent Focal Length is not found, then at least the real focal length should be in the Exif, and maybe the 1/xx inch size is shown in specifications.

The iPhone focal length is certainly NOT 26 or 28 mm, as is commonly misused. The phone body is less than 8 mm thick. Still, the internet has popular sources directly saying the phones focal length is 26 mm. That is absolutely wrong, they obviously don't understand the difference. Or some say it as the "camera is equivalent to 26 mm". That is not wrong exactly (if you realize the 26 mm is mounted on a different camera, not this one), but it is poorly worded, not useful, and it steers beginners wrong. It absolutely does NOT mean THIS phone lens is 26 mm (the phone lenses vary some, but are very roughly around 4+ mm). What Equivalence means is that this camera sees a field of view equivalent to what a 35 mm film camera would see if the 35 mm camera used the 26 mm lens. Assuming familiarity with using 35 mm film, the intended significance conveyed by 26 mm is that it is a wide angle lens (on 35 mm film), more than moderately wide, but substantially less than ultra-wide. Equivalent is the field of view referenced to the different camera. That certainly can be of interest to experienced 35 mm film users (to then know in their terms what to expect from this phone camera), but Equivalent Focal Length is of no use to the cell phone, or to a user who never used 35 mm format (except the 35 mm film format is well known, so we do have one important use for it below, to be able to compute sensor size).

Small cameras often report Sensor Size with numbers for example like "1/2.3 inch". That is NOT an accurate size of a digital sensor. There is nothing about that sensor that is 1/2.3 inches. Instead, we need to know the actual exact size of the digital sensor, which must be Width×Height numbers, in mm. Why can't they simply tell us the actual size of the camera sensor?

One method then to approximate the actual sensor Width x Height in mm from that 1/inch number is to try this Wikipedia chart. It can be approximate and incomplete, and different sensors of same description might not be the same exact mm numbers.

Another Method (which is simple math, and likely better) is to use the Option 3 with Equivalent Focal Length computing sensor size.
Repeating this:

There are issues when trying to determine the sensor size of compact or phone cameras. Also with mixed formats (both video and still photo images from the same camera). Instead of increasing the length of each calculator page affected, these issues are summarized on one place. Please see that if any issues.

More Notes:

Equivalent Focal Length depends on the sensor size and the actual Focal Length being compared. Sensor size is fixed (same one sensor for any zoom). Except new phones with separate Wide and Telephoto cameras use two sensors, which possibly are Not the same size or focal length. Those two Focal Lengths (if used) are surely in the Exif data.

The manufacturer computed Effective Focal Length from actual sensor size and focal length, so this procedure simply reverses that same calculation, which is very valid. The rounded focal lengths can cause the slightest difference, but this is actual manufacturers data, which would seem better than the mythical "1/inch" numbers. The 1% differences mentioned here seem insignificant, and are likely more accurate than your description of the Object in the photo.

Check the Exif data too, but data that comes from the camera manufacturer seems the way to go. Larger cameras normally actually specify the W×H mm sensor size directly, which is a plus (but video formats can still be an issue).

It's just simple math, so if your results don't seem reasonable, verify your inputs (including sensor size, focal length, scene distance and dimensions, and the big difference between focal length and Equivalent focal length).

## The Math

People ask about the math in the calculation. The math is similar triangles, for equal opposite angles, which are the same height/distance ratios. It could instead be done with trigonometry, but unless the degrees of angles are to be computed, geometry of similar triangles is the easy way.

The math the calculator uses is from this Thin Lens Model diagram:

Basics of lens optics:   (Dimension is Width, Height, or Diagonal)

Sensor dimension (mm)
Focal length f (mm)
=
Field dimension *
Distance to Field d *

* feet or meters (but both are same units)

Substituting an Object size instead of Field size. Using these two steps may be convenient for pixels.

Object height on sensor (mm)  =
Sensor height (mm) × Object height (pixels)

Sensor height (pixels)

Object height on sensor (mm)
Focal length (mm)
=
Real Object size *
Distance to Object *

Rearrange this formula to compute desired unknown value. Example:

Distance to Object *  =
Real Object height * × Focal Length (mm)

Object height on sensor (mm)

Real Object height *  =
Distance to Object * × Object height on sensor (mm)

Focal Length (mm)

* feet or meters (but both are same units)

This only needs the easiest high school math skills. This same math is repeated and expanded a bit at Field of View Math, so maybe see that also.

The Object Size should be in the horizontal or vertical plane, meaning Not tilted, angled or skewed, which is a serious complication. Any camera tilt up or down foreshortens height, and is a complication involving lots more math. If not tilted, these are just similar triangles as opposite angles in the diagram. In the original ratios, the sensor size and focal length are both in mm, which is one ratio. The object distance and real object size are both in either feet or meters, your choice, which is another ratio. Both sides of the lens are the same ratio, so we have an equation. The units work out OK then, we simply rearrange ratios and compute for the unknown. If we know three of the factors, we can solve for the fourth one. The calculator above will do this, but it needs your accurate numbers.

Here is a sample of a normal lens diagram (but lens vary, and the location of the nodes H and H' varies considerably, many lenses even place them a little way outside of one end or the other of the lens body). The Thin Lens Model above has the two nodes H and H' at the same place in the center of the one glass element (convenient for the math). In real camera lenses (correcting optical distortion), the two nodes are separated into separate places, perhaps close or far spacing (a "Thick Lens"), and design can put them anywhere.

The calculator must compute the object distance to the H node in the real lens (which is inches less than to the sensor plane location). A few inches are insignificant in a longer distance, but it becomes more important in close distance. The nodes are often somewhere inside the lens body, but also in many cases, the nodes are outside of the lens body. In many wide angle lenses, H' is behind the lens, between lens and sensor plane. In telephoto type lenses (most lenses of about 100 mm focal length or more), the node H' is in front of the front element of the lenses. The optical term telephoto is Not technically about magnified closer viewing the way we use it, but is instead a design term about moving node H' to just outside the front lens element (so node H is even further in front of lens), for the purpose to make the physical lens shorter than its focal length, which is a very useful feature of longer lenses. See two lens diagrams (near page bottom) for the idea of how the nodes might be located in telephoto and wide angle lenses.

Note that dimension D is the diameter of the effective aperture, affecting f/stop number and light admittance, but Not field of view. The field of view is not affected by aperture, but is the angle from point H towards the outer edges of the lens, and from H' to the sensor size edges internally. Field of view is of course affected by focal length, but whatever comes out of the lens is actually limited by what the sensor size can capture, which is why a smaller sensor limits the field of view of a wider lens, reduced by the crop factor.

Finding that node: People make very wide panoramic images by stitching several images together that were taken while rotating the camera in steps. However they must rotate the camera around the axis of that same H node apex location, otherwise parallax causes messy problems of joining the images. The point here is that they do have a way to find this same lens node accurately that should work here too. See Google for their method of finding the node to correct panoramic parallax. Here is one of articles that I like (explains things very clearly and well). Your goal may not be doing this to take panoramic photos, but just done once to know where this distance node is, and I am imagining that I could do this the following way:

That Google search also shows brackets to hold the camera out from the tripod so that the tripod rotates around that axis out near the lens, so keep in mind that while finding it, you have to rotate the camera around that same axis (to find that axis). A try that might work without buying a bracket would be to drill a 1/4 inch hole near the end of a 12 inch ruler, and fasten it to the camera tripod socket with a very short UNC 1/4"-20 screw, similar length to the camera screw in the tripod (1/4"-20 screw is extremely standard in any U.S. hardware store, but short could be an issue ... Home Depot might have the largest choice), with the ruler aimed forward under the lens. Just rest the end of the ruler to sit on the tripod head (don't attach it), and keep the camera level as you hand-hold the camera, varying the ruler measurement to view the parallax. The ruler measurement at the tripod will let you repeat and/or adjust that distance. You don't have to actually take pictures, but just vary it until no parallax is seen, and then the ruler scale will tell you an exact point (dimension to a point on the lens). At worst, you might need a helper to monitor the ruler measurement, and to watch for your not keeping the camera on it and level, and maybe even to hold the ruler down on the tripod head with their hand. But for this distance calculator, you only need to know the point that your lens measures from. Like the distance from the front of the lens perhaps.

Know that this H node location does vary in each lens, and varies with zoom and the focused distance, but it could be a better ballpark than the sensor plane location at the back of the camera.

So the easy way is to just use the calculator above. But any plan will still require that you to use the correct sensor size and focal length of your camera. But if your goal is otherwise, this math part couldn't be easier. The pixels determine the percent of sensor mm height occupied by the Object. It's the same percentage of the distant field.

The difficult part is determining accurate sensor dimensions and accurate focal length (not easy in simpler cameras). I worry about your finding the right specifications, especially for compacts or phones. Vague questionable input gives vague questionable output. More bluntly, garbage in, garbage out. It won't be greatly precise, but if your results don't seem reasonable, verify your inputs.