fix fatal on invalid image

fix fatal on invalid image