This paper is primarily an investigation of whether the `optimal extraction' techniques used in CCD spectroscopy can be applied to imaging photometry. It is found that using such techniques provides a gain of around 10 per cent in signal-to-noise ratio over normal aperture photometry. Formally, it is shown to be equivalent to profile fitting, but offers advantages of robust error estimation, freedom from bias introduced by mis-estimating the point spread function, and convenience. In addition some other techniques are presented, which can be applied to profile fitting, aperture photometry and the `optimal' photometry. Code implementing these algorithms is available at http://www.astro.keele.ac.uk/~timn/.