Light travels in a straight line and when some of the rays are shone from a bright subject through a small hole in thin material they do not scatter but cross and reform as an upside down image on a flat surface held parallel to the hole. This law of optics was known in ancient times it is called camera obscura
These are some examples of camera obscura done in rooms