ImageMagick Brew installation with PHP Module in M

2020-01-29 05:21发布

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

12条回答
贼婆χ
2楼-- · 2020-01-29 06:17

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
查看更多
SAY GOODBYE
3楼-- · 2020-01-29 06:17

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'));"
查看更多
爷、活的狠高调
4楼-- · 2020-01-29 06:23

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.

查看更多
贪生不怕死
5楼-- · 2020-01-29 06:23

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....

查看更多
We Are One
6楼-- · 2020-01-29 06:25

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

here

查看更多
萌系小妹纸
7楼-- · 2020-01-29 06:26

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

Example:

extension = /usr/local/Cellar/php55-imagick/3.1.2_1/imagick.so
查看更多
登录 后发表回答