Skip to main content

Command Palette

Search for a command to run...

Install ImgMagick for PHP on MacOS

Updated
1 min read
Install ImgMagick for PHP on MacOS

When it comes to image handling (from multiple things like crop, sizing,...). You won't use normal GD of PHP, it sucks.

You will use a library instead, and ImageMagick is quite awesome in terms of that.

From PHP, ImageMagick also offers a native extension for us to install. Which I'm about to show you below!!

I'll use brew and pecl for the installation.

Prepare

If you haven't installed this, run it:

brew install pkg-config zlib

Additionally, you might need to do this as well, in order to make the installation go smoothly.

ln -s /opt/homebrew/Cellar/pcre2/10.39/include/pcre2.h /opt/homebrew/Cellar/php/8.1.0_1/include/php/ext/pcre/pcre2.h

Install

brew install imagemagick
pect install imgmagick

If you see this "Extension imagick enabled in php.ini" after the command. Then congrats!

More from this blog

S

Seth Phat Tech Blog

69 posts

develops awesome software, contributes to OSS, writes tech tips, and loves Vietnamese milk coffee!