fit grid size for image