How to check the integrity of an image