Did you also install Ghostscript? I have "ghostscript9-nox11-9.06" installed which is a dependency of Imagemagick.
Maybe with PHP-FPM (which uses the 'www' user with a limited shell) ghostscript isn't accessible? But it is accessible when I run the script from the commandline?