Validate images using Imagick before adding them

This PR adds stricter checking to incoming images using Imagick - this makes sure we don't rely on image size alone.