Posts Learn Components Snippets Categories Tags About
/

How to install Imagick on MacOS system

In this post you will learn how to install imagick on MacOs using Homebrew

9 months ago

5 mins read

303 views

In this post, I assume that everyone has already installed PHP with Homebrew. if you have not done so, do run the command below.
brew install php

Check if Imagick is already installed


Before starting do check whether Imagick is already installed in the system.
php -m | grep imagick
If the response is blank that would mean Imagick is not installed.

Install Imagick dependency


The first thing to do is to install the necessary dependency for the setup. Do note that it will take some time to install the necessary dependency.
brew install pkg-config imagemagick

Install Imagick through PECL


Once that's done, run the command below to install Imagick using PECL command line.
pecl search imagick
pecl install imagick
brew services restart php

Update: 16/6/2021


If you are using macOS M1 and PHP version 7 or 8 and having some issues, do run the command below one at a time. Do specify your own PHP version below otherwise, it won't be able to symlink the file.
# install pcre2
brew install pcre2

# symlink the required file
ln -ln -s /opt/homebrew/Cellar/pcre2/10.37/include/pcre2.h /opt/homebrew/Cellar/php/8.0.6_1/include/php/ext/pcre
Install Imagick directly from the source, make sure to run the command one line at a time.
git clone https://github.com/Imagick/imagick

cd imagick

phpize && ./configure

make

make test

make install
Once it's installed, edit your php.ini file and add the line extension="imagick.so". Finally, restart your PHP with the command below.
brew services restart php

# or if using laravel valet
valet restart
By now you should have Imagick installed and you can test it by running the command above and get a response "imagick" in the terminal.

Load comments for How to install Imagick on MacOS system

new

PostSrc Code Snippets

Learn new snippets today, level up your Laravel, Alpine JS, Vue JS, Tailwind CSS skills and more.

Learn New Snippets

Authored by

PostSrc poster

PostSrc

Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

new

PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your project.

View Components