How to install imagick via homebrew?

I am trying to install imagick using homebrew. The issue is that MagickWand libaries cannot be found.

$ brew install php54-imagick
==> Downloading http://pecl.php.net/get/imagick-3.1.0RC2.tgz
Already downloaded: /opt/boxen/cache/homebrew/php54-imagick-3.1.0RC2.tgz
==> Patching
patching file imagick-3.1.0RC2/config.m4
==> PHP_AUTOCONF="/opt/boxen/homebrew/opt/autoconf/bin/autoconf" PHP_AUTOHEADER="/opt/boxen/homebrew/opt/autoconf/bin/autoheader" /opt/boxen/homebrew/Cellar/php54/5.4.26/bin/phpize
==> ./configure --prefix=/opt/boxen/homebrew/Cellar/php54-imagick/3.1.0RC2 --with-php-config=/opt/boxen/homebrew/Cellar/php54/5.4.26/bin/php-config
checking for awk... awk
checking if awk is broken... no
checking whether to enable the imagick extension... yes, shared
checking whether to enable the imagick GraphicsMagick backend... no
checking ImageMagick MagickWand API configuration program... configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.

READ THIS: https://github.com/Homebrew/homebrew/wiki/troubleshooting
If reporting this issue please do so at (not Homebrew/homebrew):
  https://github.com/josegonzalez/homebrew-php/issues

There is an issue on github for that bug yet it got closed. There seemed to be a fix for that bug, but it got closed and cherry-picking is not possible for me.


As mentioned on this answer : https://stackoverflow.com/a/17848864/2307070

you can try these steps:

wget http://pecl.php.net/get/imagick-3.1.0RC2.tgz
tar zxf imagick-3.1.0RC2.tgz

Edit the file imagick-3.1.0RC2/config.m4 line number 55.

Make changes like this, from

if test -r $WAND_DIR/include/ImageMagick/wand/MagickWand.h;

to

if test -r $WAND_DIR/include/ImageMagick-6/wand/MagickWand.h;

Note this difference made in the imagick version number. After that try the conventional installation procedures

cd imagick-3.1.0RC2
phpize
./configure
make
make install

I was able to install imagick via pecl by providing the config path.

which Wand-config outputs /opt/boxen/homebrew/bin/MagickWand-config.

I removed the bin part, hence the parameter I used for sudo pecl install imagick was /opt/boxen/homebrew/.

This succeeded stating:

Build process completed successfully
Installing '/opt/boxen/homebrew/Cellar/php54/5.4.26/include/php/ext/imagick/php_imagick.h'
Installing '/opt/boxen/homebrew/Cellar/php54/5.4.26/include/php/ext/imagick/php_imagick_defs.h'
Installing '/opt/boxen/homebrew/Cellar/php54/5.4.26/include/php/ext/imagick/php_imagick_shared.h'
Installing '/opt/boxen/homebrew/Cellar/php54/5.4.26/lib/php/extensions/no-debug-non-zts-20100525/imagick.so'
install ok: channel://pecl.php.net/imagick-3.1.2
Extension imagick enabled in php.ini

I see this way as a workaround, not as a fix. It would be great if it was possible using brew directly.