The image formed in a pinhole camera is inverted. Why?
Because of the rectilinear propagation of light.
Light travels in a straight line. Thus light from the top of the object after passing through the pinhole will reach the bottom of camera screen and light from the bottom of the object will pass through the pinhole and reach the top of the screen. This will cause inversion of the image. See the image below: