Installing ImageMagick on MacPorts and imagick on PECL

Over the last few hours I’ve installed ImageMagick on MacPorts (super easy), and imagick on PECL (not so much). Xentek‘s post on ImageMagick and imagick was a great help, and got me past the first brick wall I hit (passing in the ImageMagick prefix to prevent it complaining about Wand-config)… but then I couldn’t get the darned extension installed. Anyway, here’s the steps I went through, and if anyone has any suggestions for improvements I’m all ears.

Installing ImageMagick through MacPorts is simplicity itself:

sudo port install ImageMagick

Then you need to install imagick, the PHP extension which wraps ImageMagick for convenience (note the sudo, which some commentators missed in articles I read):

sudo pecl install imagick

After lots of scrolling bumpf, you will be told ” 1. Please provide the prefix of Imagemagick installation : autodetect”, followed by a prompt “1-1, ‘all’, ‘abort’, or Enter to continue:”. As suggested by Xentec, here I hit 1, then entered:

/opt/local

Where I differed from Xentec was on the final line. Bizarrely my imagick.so extension file didn’t end up where PHP was expecting so I had to find it with Spotlight and drop a full path into php.ini as follows:

[imagemagick]
extension="/opt/local/lib/php/extensions/no-debug-non-zts-20060613/imagick.so"

Of course your imagick.so may be somewhere else, and it might just have been me that’s messed something up somewhere along the lines, so you probably should try this first instead:

[imagemagick]
extension="imagick.so"

If that doesn’t work, you’ll see a line in your PHP error log similar to this one (and you won’t be able to use the extension):

PHP Warning: PHP Startup: Unable to load dynamic library './imagick.so' - (null) in Unknown on line 0

One thought on “Installing ImageMagick on MacPorts and imagick on PECL”

Leave a Reply

Your email address will not be published. Required fields are marked *