Home » Php » macos – ImageMagick Brew installation with PHP Module in Mac OS X

macos – ImageMagick Brew installation with PHP Module in Mac OS X

Posted by: admin April 23, 2020 Leave a comment


I have installed ImageMagick using brew install imagemagick. This all worked fine and I can run any ImageMagick command from the Terminal / Command line.

Now when I try to use the ImageMagick classes in PHP, I get an error Class 'Imagick' not found in .... I guess this is because the ImageMagick module is not loaded.

Could anyone help me to get this thing working in PHP? Thanks!

Additional info:
Mac OS X Version: 10.8: Mountain Lion
PHP Version: 5.3.13

How to&Answers:

Your ImageMagick installation is not enough. You also need the Imagick package (possibly called php72-imagick or similar for home brew).

Imagick doesn’t do the work itself, it is a native PHP extension for creating and modifying images using the ImageMagick API.

Try to search for the exact name of the package via brew search imagick.


I just did this after a lot of experimenting. For now, this seems to be the way to do it for php 5.3:

brew tap josegonzalez/php
brew tap homebrew/dupes
brew install php53-imagick

No idea who Jose Gonzalez is but apparently we are in his debt….


I’m using Yosemite. For me, the solution is a combination of the answer and comment already listed here.

brew install imagemagick
brew install php55-imagick

Edit /etc/php.ini to include imagick

extension=/usr/local/Cellar/php55-imagick/{version of php55-imagick}/imagick.so


extension = /usr/local/Cellar/php55-imagick/3.1.2_1/imagick.so


php72-imagick is now deprecated as imagick is part of php binary itself. Use pecl to install imagick e.g.:

brew install php
brew install imagemagick
brew install pkg-config
pecl install imagick


I had the same issue. These are the steps that worked for me if you are using php 5.6

  1. brew install php56-imagick
  2. brew install imagemagick
  3. find /usr/local/Cellar -name "imagick.so"
    copy the path from the output of this command into your php.ini file
    e.g. extension=/usr/local/Cellar/php56-imagick/3.3.0_2/imagick.so
    save your file. Now to double check that the imagemagick class exists type
  4. php -r "print(class_exists('imagick'));"

Brew symlinking wasn’t working for me so I had to put the full pathname into the php.ini file to get it to work.
Hope this helps


this one worked for me:

brew install imagemagick       # If it's not already installed
mkdir /usr/local/lib/php/pecl  # On my system this dir didn't exist and this caused pecl install to fail
pecl install imagick




brew install homebrew/php/php53-imagick


I’ve looking for correct way to install imagick on Mojavie and found solution that fully worked.

  1. brew install [email protected]
  2. brew install [email protected]
  3. Install headers (Xcode-select –install)
  4. Download imagick source code from: https://pecl.php.net/package/imagick
  5. Open terminal and enter unzipped folder imagick-3.4.3/imagick-3.4.3 (in my case)
  6. Run command phpize
  7. ./configure
  8. make

And now if error occurs like MagicWand not found, edit file Makefile and look for CPPFLAGS = -I/usr/local/opt/[email protected]/include/. Inspect if in include folder there is no other folder. In my case it should be like this:
CPPFLAGS = -I/usr/local/opt/[email protected]/include/ImageMagick-6

save and return to terminal and type make (after finished)
sudo make install

imagick.so is located in imagick-3.4.3/imagick-3.4.3/modules


Ok after 1 hour at this I have figured it out. The mac is not giving the pecl script permissions to make a PHP directory. To resolve do as follows.

brew install imagemagick
Sudo pecl install imagick .  
php --ini | grep "Loaded Configuration File"
Add extension=imagick.so under extensions.

The install will be complete. Then, to test run:

php -r "print(class_exists('imagick'));"


From: php error: Class 'Imagick' not found

Did you add extension=imagick.so to your php.ini (or /etc/php.d/imagick.ini) file?


I had the same error having already installed imagemagick and php71-imagick.

brew upgrade imagemagick – did the trick for me.

You may need sudo:

sudo brew upgrade imagemagick

You may need to restart apache / php-fpm / <other webserver>.


I cannot add comments because of reputation, but to add to this anwser:

answered Apr 12 at 16:52

Grzegorz Miśkiewicz

I was getting a missing php.h file, so as per Installing xdebug on MacOs Mojave – 'php.h' file not found I installed the necessary file via the below command:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /