  Effective and unrestricted engineering of atom-photon interactions requires
precise spatially-resolved control of light beams. The significant potential of
such manipulations lies in a set of disciplines ranging from solid state to
atomic physics. Here we use a Zeeman-like ac-Stark shift of a shaped laser beam
to perform rotations of spins with spatial resolution in a large ensemble of
cold rubidium atoms. We show that inhomogeneities of light intensity are the
main source of dephasing and thus decoherence, yet with proper beam shaping
this deleterious effect is strongly mitigated allowing rotations of 15 rad
within one spin-precession lifetime. Finally, as a particular example of a
complex manipulation enabled by our scheme, we demonstrate a range of
collapse-and-revival behaviours of a free-induction decay signal by imprinting
comb-like patterns on the atomic ensemble.
