Check if image is valid