Use length of image array for modulo