Sorry if this is a really badly worded question. Say you have a box of unknown size, and a planar object of a known size (say, a credit card).
You arrange these object somehow (probably with the card aligned with two of the boxes axes) and take a picture of them.
Knowing the exact size of the card, is there any maths I could use to calculate the exact size of the box? Would I have to move the card and take another picture to get the size along the 3rd axis?
A photo is usually a projection, the conserved quantity in a projection is the cross ratio of four points on a line. So, for calculation purposes, you want to already know that your credit card shares lines with your box. This approach indeed necessitates more than one picture.
We will just look at one side of the box and the credit card now, the other calculation is analogous:
Now, measure in your photo $a=$ length from corner to mid-point of credit card side, $b=$ length from mid-point of credit card side to end of credit card side, $c=$ length from corner to other corner of unknown box and $d=$end of credit card side to other corner of unknown box.
Denote $l$ the length of this side of the credit card and $x$ the unknown length of the side of the box.
You have: $$\frac{a}{b}\frac{d}{c}=\frac{x-l}{x}.$$
So, $$x= \frac{lbc}{bc- ad}.$$
Two points, their mid-point and the point at infinity of that line have cross-ratio -1. The two parallel sides of the credit card intersect at the point at infinity. Therefore, with $a,b$ as above, $e$ the length of the credit card in the picture and $m$ the distance of the beginning of the credit card side to the intersection of the credit card side with its "parallel" one in the picture, you get: $$\frac a{e-a} \frac {m-e}{m} = -1$$
which permits you to calculate $a$.