Automatic loop centring has been developed as part of the automation process in crystallographic data collection at the Swiss Light Source. The procedure described here consists of an optional set-up part, in which the background images are taken, and the actual centring part. The algorithm uses boundary and centre-of-mass detection at two different microscope image magnifications. Micromounts can be handled as well. Centring of the loops can be achieved in 15-26s, depending on their initial position, and as fast as manual centring. The alignment of the sample is carried out by means of a new flexural-hinge-based compact goniometer head. The device features an electromagnet for robotic wet mounting of samples. The circle of confusion was measured to be smaller than 1 µm (r.m.s.); its bidirectional backlash is below 2 µm.