The thing is, a pinhole is not a lens. It doesn't even act like a
lens. It doesn't focus, or magnify or bend or do anything to the paths
of the light rays which pass through it. It just allows light rays,
which conveniently (for our purposes) travel in straight lines, to
pass through it. They end up striking the back wall of the
camera. It's really quite obvious, as soon as we give up our
lens-centric view of the world.
This of course ignores the diffraction effect, which _does_ bend
the light path, but this is still not related to the distance of the
object from the camera.
Patrick Jordan.