Move imagemagick detection back to _api.py.

Also, only invoke it if SANPERA_BUILD is set to 'y' or so, or if running from
setup.py.