Let x be the distance the camera is from the painting.
Then, we have two triangles.
Angle is the one we need.
So, we have
Differentiate, set to 0 and solve for x.
We could also use cot:
A photographer is taking a picture of a four-foot painting hung on the art gallery. The camera lens is 1 foot below the lower edge of the painting. How far should the camera be from the painting to maximize the angle subtended by the camera lens?