Resolved: MAMP Php can't exec ('convert') after Homebrew ImageMagick install

这一生的挚爱 提交于 2019-12-02 18:23:21

Adding my own answer here so you can vote:

It was caused by MAMP, here is the fix: http://firedevcom.tumblr.com/post/22791937644/fix-for-homebrew-imagemagick-and-mamp

Open /Applications/MAMP/Library/bin/envvars

And comment out the following lines:

DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH

Done.

NiLL
sudo ln -s /usr/local/bin/convert /usr/bin/convert

Verify that convert in is the server's PATH environment variable. Or just specify the full path:

exec('/usr/local/bin/convert -version');

The exec returns the last line from the result of the command which happens to be an empty string. If you want to get the output, just do something like this:

exec('convert -version', $output);
var_dump($output); // it is an array which filled with every line of output from the command

Simply use exec("PATH=\$PATH:/usr/local/bin; convert file.pdf file.png"); It will add convert to PATH on runtime.

instead of just exec("convert .... "); use a full path. you can get it by typing the terminal

type convert

you should get something like: convert is hashed (/opt/local/bin/convert)

so now use:

exec("/opt/local/bin/convert .... ");

[credits to @Nikki]

after that comment out

DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH" export DYLD_LIBRARY_PATH

in /Applications/MAMP/Library/bin/envvars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!