By Sebastiaan de Jonge, published on Monday, December 3, 2012 at 10:26

After having stumbled upon the same problem twice this month I have decided to write a short tutorial about it. For me this was the quickest way to get ImageMagick working with MAMP 2.x on my OSX (10.8.x).

MacPorts

The easiest way (for me at least) was to start by installing MacPorts. This nifty tool allows you to install many tools which were ported to nicely on OS X. The installation is simply done via a .pkg file. Choose the one that's suitable for your OS version here.

https://distfiles.macports.org/MacPorts/

ImageMagick

After installing you will need to open terminal. We will start by updating MacPorts, after which we can continue with the installation of ImageMagick.

# Update the base sources and the ports tree
sudo port selfupdate
# Install ImageMagick
sudo port install ImageMagick

Because ImageMagick has quite some dependancies, the installation of this might take a while. Depending of course on several factors. But, be patient. It's worth it.

PHP 5.3.x + PHP ImageMagick module

Once ImageMagick is installed, we will need to get the ImageMagick PHP module. This can be done by installing PHP via MacPorts and then installing the ImageMagick module for PHP. Simply run the following commands to do both.

# Install PHP 5.3.x
sudo port install php53
# Install the ImageMagick module for PHP
sudo port install php53-imagick

Disable DYLD_LIBRARY_PATH

Almost there, just a small tweak that has to be done for it all to work. We will need to disable the DYLD_LIBRARY_PATH variable in Apache's environmental variables. Edit the file with your favorite editor (vim, mcedit or whatever you prefer).

vim /Applications/MAMP/Library/bin/envvars

And comment out the following two lines:

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

Now finally restart your MAMP servers and you're all done. ImageMagick should now be available under the path /opt/local/bin/ (you will need to set this in your TYPO3 install tool or localconf.php file if you are using TYPO3).

Additionally you can check if the ImageMagick module is loaded by printing the PHP Info.

Comments

Georg Scherg
Georg Scherg - Sunday, December 30, 2012 at 15:28

Thanks for your utmost helpful tutorial ...Save me hours of work configuring TYPO3 for ImageMagick! Thank's a lot ...

Saugrin Sonia
Saugrin Sonia - Wednesday, April 24, 2013 at 12:34

Merci pour le tuyau, je travail d'habitude sous Ubuntu c'est simple, pour ce qui est de serveur web

Ed
Ed - Thursday, January 16, 2014 at 20:21

After combing the internet for a solution to this issue, I finally found your post. I followed your instructions and inserted one or two things to suit my needs, but your post actually helped me solve my problem. In a quick summary, these are the steps I took for MAMP 2.2 and PHP 5.5.3:

sudo port selfupdate
# it might be necessary to do this linkage to the right php-version to avoid problems while installing ImageMagick
sudo ln -s /Applications/MAMP/bin/php/php5.5.3/bin/php /opt/local/bin/php
sudo port install ImageMagick
sudo port search php5 // to determine the exact name of the file for php5.5.3
sudo port install php55
# to determin the exact ImageMagick file to install for php5.5.3
sudo port search ImageMagick
sudo port install php55-imagick
# determine exact path of image magick extension for php
sudo find /opt/ -name *imagick.so*```

-> Include imagick.so path in php.ini:

extension=""/opt/local/lib/php55/extensions/no-debug-non-zts-20121212/imagick.so""

-> Comment out the following lines in sudo /Applications/MAMP/Library/bin/envvars

    #if test ""x$DYLD_LIBRARY_PATH"" != ""x"" ; then
    #  DYLD_LIBRARY_PATH=""/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH""
    #else
    #  DYLD_LIBRARY_PATH=""/Applications/MAMP/Library/lib""
    #fi
    #export DYLD_LIBRARY_PATH
sudo /Applications/MAMP/bin/stopApache.sh
sudo /Applications/MAMP/bin/startApache.sh
Franky
Franky - Friday, January 31, 2014 at 06:22

I went through every single step in Ed's comment - and it all works great!

I am on Mavericks 10.9.1 / Mamp Pro 2.2 / XCode 5.0.2 and XCode 5.1-beta4

I did however change the double apostrophes inextension=""/opt/local/lib/php55/extensions/no-debug-non-zts-20121212/imagick.so"" to single ones

Thanks a bunch guys, I really don't understand why MAMP doesn't install this great .so by default.GD always gives me weird stuff like black backgrounds on PNG resize etc ...