Friday, October 29, 2010

imagick for XAMPP on Mac Leopard

There are different options to install/use PHP on Mac Leopard: use the default installation, use MacPort to install, or use XAMPP.

I like the all-in-one bundle XAMPP, it is easy to manage and includes most commonly used options. So, I use it for the most of the time. However, when I need to install imagick, a PHP wrapper for ImageMagick, I got into some troubles.

First, this package is not available via PEAR or PECL (PECL got into some errors). So, I end up manually compile imagick and copy the into XAMPP extension directory. Here is what I did:

  1. change PATH to use default Leopard PHP installation, i.e. put /usr/bin ahead of XAMPP bin directory in PATH setting

  2. use MacPort to install ImageMagick (assume you have MacPort installed, Yahoo! it if you did not know how to)

  3. go to, and find out the latest release

  4. manually build imagick and copy to XAMPP PHP extension directory (assuming using PHP5)

    curl -O
    tar xvfz imagick-2.2.2RC1
    cd imagick-2.2.2RC1
    ./configure --with-imagick=/opt/local
    sudo make install (we are using /usr/bin/php, so the is created in /usr/lib/php/extensions/no-debug-non-zts-20060613/)
    sudo cp /usr/lib/php/extensions/no-debug-non-zts-20060613/ /Applications/xampp/xamppfiles/lib/php/php5/extensions/no-debug-non-zts-20060613/

  5. edit /Applications/xampp/etc/php.ini, find “Dynamic Extensions” block, add
    6. testing, add this test.php file to /Applications/xampp/htdocs and try it at http://localhost/test.php, you will see this jpg turned 45 degree clockwise (get santa-claus.jpg from here)

    < ?php
    $img = new Imagick('santa-claus.jpg');
    $img->rotateImage(’#fff’, 45);
    header(’Content-type: image/jpeg’);
    echo $img;


No comments:

Post a Comment