How to parse an image that was just uploaded to make sure it doesn’t contain malicious code?

How to parse an image that was just uploaded to make sure it doesn’t contain malicious code?