Homebrew PHP – Fixing Imagemagick and php54-imagick Issues

homebrewmacosPHP

Based on this post here, I am having a versioning issue with Imagemagick.

  • php54-imagick version => 3.4.3_2
  • imagemagick => 7.0.5-3

I understand that I need to downgrade my imagemagick to 6.9.*

My issue:

brew install php54-imagick

Automatically installs the required imagemagick 7.0.5-3 package

I uninstall imagemagick 7.0.5-3

brew uninstall --ignore-dependencies imagemagick

I install imagemagick 6.9.* (6.9.8-1 to be specific)

brew install imagemagick@6

The error:

macos1:~ $ php -i | grep imagick

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/opt/php54-imagick/imagick.so' - dlopen(/usr/local/opt/php54-imagick/imagick.so, 9): Library not loaded: /usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.0.dylib
  Referenced from: /usr/local/opt/php54-imagick/imagick.so
  Reason: image not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php54-imagick/imagick.so' - dlopen(/usr/local/opt/php54-imagick/imagick.so, 9): Library not loaded: /usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.0.dylib
  Referenced from: /usr/local/opt/php54-imagick/imagick.so
PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0
Additional .ini files parsed => /usr/local/etc/php/5.4/conf.d/ext-imagick.ini

The question:

How would I use php54-imagick version 3.4.* with imagemagick 6.9.*?

Best Answer

I have resolved my own issue! Since I was using the readImage method from ImageMagick class, it required ghostscript to be installed alongside ImageMagick.

However, when you brew install imagemagick, ghostscript is an optional dependency that is not installed by default.

To resolve my issue, here is what I did (all the steps):

  1. brew install php54-imagick
  2. brew install imagemagick --with-ghostscript

Now I can readImage('test.pdf')!