only call getImageData once