Reset the image margins if it exceeds the maximum image size (see #7245)