Diffraction; Pinhole diffraction
Diffraction is where the light wave entering an aperture in the photographic lens is affected by contact with the edges of the aperture hole itself. Equally diffraction can occur at any small hole or very fine slit where light may pass through.
A wave front passing the aperture edge is bent a tiny amount as part of the wave hits the aperture sides. At most apertures the effect is minimal. The picture will be sharp.
At very narrow apertures the effect on the wave as it passes the edge of the aperture can be significant. In most cases the image will be slightly soft. In extreme cases, the light is bent to the extent that the image cannot be resolved and is blurred.
The impact of diffraction will rarely be noticeable until around f22 on some lenses and maybe even narrower (f32 etc).
How diffraction works
Diffraction is where light is passing though a very small gap. As it does so some of the light bounces off the edge of the small gap. As it bounces back, away from the gap edge, the light crosses some of the light waves passing through the gap. When a wave peak meets a wave peak a bright spot is formed (the lights from two peaks are added together making more light energy). When a light-wave-trough meets a light-wave-peak they cancel each other out. This makes a dark, low energy spot.
As you can see from the diagram below, this diffraction pattern creates a set of concentric circles of brighter and darker areas. Anti-diffraction coatings on the aperture, lens and nearby components help even out that pattern on the lens element nearest to the aperture.
Diffraction occurs around the aperture edge. But it also would happen when a pin-hole camera is used. The very small hole, used as a focusing point for the shot, can also create these diffraction patterns. However, the longer the exposure the less the effect will be seen. As pin-hole cameras usually need very long exposures the concentric circles effect is rarely a problem. However, the focus will be affected with some pin-hole sizes.
The diagram shows an approximation of the concentric pattern of light circles as it would appear on the image plane on the sensor. In this extreme case the image would not resolve and would probably be unrecognisable.
When using extremely narrow apertures check the sharpness/softness of the image. If the image is soft, open the aperture by a half or full stop to bring the resolution back into normal levels.
More technical information including a full explanation of the creation of the light patterns formed by diffraction, and the mathematical formula which model the effects can be found here: Diffraction on Wikipedia – full technical details .