Fixed the error of check the range of image