  We show that the magnetic anisotropy in spinel-structure CoCr$_2$O$_4$ thin
films exhibits a strain dependence in which compressive strain induces an
out-of-plane magnetic easy axis and tensile strain an in-plane easy axis,
exactly opposite to the behavior reported for the related compound
CoFe$_2$O$_4$. We use density functional theory calculations within the LSDA+U
approximation to reproduce and explain the observed behavior. Using
second-order perturbation theory, we analyse the anisotropy tensor of the
Co$^{2+}$ ions in both octahedral and tetrahedral coordination, allowing us to
extend our results to spinels with general arrangements of Co$^{2+}$ ions.
