Install XCode + the Command-Line Tools. (CL tools are not bundled with
Xcode 4.3 by default anymore and should contain build tools such as
gcc
(confirm with whatever version you are using). XCode app (found on the
AppStore) is easy to install but the CL Tools can only be installed within XCode
as an optional install on the Components tab of the Downloads preferences
panel.
Install Homebrew which will be used to install libs/components as well as manage the dependencies for us.
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Install ImageMagick.
$ brew install imagemagick
Installing a PHP53 compatible version of Imagick … first let Homebrew search the formula for you
$ brew search php53-imagick
… OR …
$ brew search imagick
The above searches should return something like ‘josegonzalez/php/php53-imagick’ … use this for the next step:
$ brew install josegonzalez/php/php53-imagick
If you get “No formula & taping” errors …
Error: No available formula for XYZ
Please tap it and then try again: brew tap XYZ
… do as you’ve been told, and run the ‘brew tap’ … command exactly as the error told you. After that, repeat the step which caused that error.
Now edit MAMP config & add the extension to MAMP Pro’s php.ini. In MAMP Pro go
to the menubar, and choose File > Edit Templates > PHP > PHP x.x.x php.ini
. A
simple editor window will popup where you can edit the ini file. A search for
the term ‘extension=’, will lead you to a block with various lines of
‘extension=…’. Now simply ad the following one and save the file:
$ extension="/usr/local/Cellar/php53-imagick/3.1.0RC2/imagick.so"
Copy libfreetype to MAMP lib (freetype version in path may vary)
$ cp /usr/local/Cellar/freetype/2.4.11/lib/libfreetype.6.dylib /Applications/MAMP/Library/lib/
Fix library version incompatibilities by open the file
/Applications/MAMP/Library/bin/envvars
in the editor, and comment out the
following lines:
$ cDYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
$ export DYLD_LIBRARY_PATH
Restart MAMP and check the phpinfo tab: a search for the term imagick
should
bring you to a section reading like so:
imagick module version 3.1.0RC2
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version ImageMagick 6.7.7-6 2012-09-18 Q16 http://www.imagemagick.org
ImageMagick copyright Copyright (C) 1999-2012 ImageMagick Studio LLC
ImageMagick release date 2012-09-18
ImageMagick number of supported formats: 191
Ps: Original post - see footnote #4, has extra’s on enabling tiff support
After installing Imagemagick using Homebrew on Lion, everything is fine except that it doesn’t work at all when being called from php.
exec ('/usr/local/bin/convert') // works, but
exec ('which convert') // doesn't
Turns out, for php to work convert should be in /usr/bin/ so this solved it:
$ ln -s /usr/local/bin/convert /usr/bin/convert
This article was originally linked to this … which is now broken. I’ve also update Homebrew links which seem to have moved. Thanks to @CreativityKills for the heads up.