Skip to content

Installing ImageMagick on Mac OSX for PHP and MAMP

Bryan Hazelbaker edited this page Jun 6, 2013 · 25 revisions

Manual Installation

Install Ghostscript

Ghostscript is going to be doing the actual conversion for ImageMagick

  1. brew install ghostscript

If there is a failure try running brew update and then the command again.

Compile ImageMagick

ImageMagick must be compiled with ghostscript support to convert PDFs to images.

  1. brew install ImageMagick --with-ghostscript

After the above you should be able to execute convert -list delegate and see some entries for pdf.

Create PHP imagick.so extension

PHP will use ImageMagick through the extension imagick.so

  1. pecl install imagick
  2. Copy the imagick.so file into MAMP's directory:
  3. php --ini | grep "Loaded Configuration File
  4. cat /Applications/MAMP/bin/php/php5.3.6/conf/php.ini | grep extension_dir

If you receive the error: php_imagick.h:40:10: fatal error: 'php.h' file not found then please reference: MAMP doesn’t ship with a bunch of the PHP sources

Configure PHP to use imagick.so extension

Configure php.ini to use imagick.

extension=imagick.so

Force MAMP to use system libraries. This may be helpful if you encounter errors such as Symbol not found: __cg_jpeg_resync_to_restart. Comment out references to DYLD_LIBRARY_PATH. This can have unintended consequences!

vi /Applications/MAMP/Library/bin/envvars

Make sure Apache has access to ghostscript. Only if convert runs fine from the command line but fails under php. (http://stackoverflow.com/questions/588918/imagemagick-imagick-convert-pdf-to-jpg-using-native-php-api)

ln -s /usr/local/bin/gs /usr/bin/gs

Clone this wiki locally