(Abridged) We present new optical and near-infrared imaging for a sample of 98 spectroscopically-selected galaxy groups at 0.25<z<0.55. We measure accurate colours for group members and the surrounding field population, statistically complete above a stellar mass limit of M=1E10 Msun. The overall colour distribution is bimodal in both the field and group samples; but at fixed luminosity the fraction of group galaxies populating the red peak is larger, by 20+/-7 per cent, than that of the field. In particular, group members with early-type morphologies, as identified in HST imaging, exhibit a tight red sequence, similar to that seen for more massive clusters. We show that approximately 20-30 per cent of galaxies on the red sequence may be dust-reddened galaxies with non-negligible star formation and early-spiral morphologies. This is true of both the field and group sample, and shows little dependence on near infrared luminosity. Thus, the fraction of bright group members with no sign of star formation or AGN activity is 54+/-6 per cent. Our field sample, which includes galaxies in all environments, contains 35+/-3 per cent of such inactive galaxies, consistent with the amount expected if all such galaxies are located in groups and clusters. This reinforces our earlier conclusions, that dense environments at z<0.5 are associated with a premature cessation of star formation in some galaxies; in particular we find no evidence for significantly enhanced star formation in these environments. Simple galaxy formation models predict a quenching of star formation in groups that is too efficient, overpopulating the red sequence. Attempts to fix this by increasing the timescale of this quenching equally for all group members distorts the colour distribution in a way that is inconsistent with observations.