Install imagick on mac

我与影子孤独终老i 提交于 2020-05-14 18:21:12

问题


I need to install imagick extension for php. I have already installed Image Magick. Then I did "sudo pecl install imagick". After this I had such output in console:

Installing '/usr/include/php/ext/imagick/php_imagick.h'
Installing '/usr/include/php/ext/imagick/php_imagick_defs.h'
Installing '/usr/include/php/ext/imagick/php_imagick_shared.h'
Installing '/usr/lib/php/extensions/no-debug-non-zts-20090626/imagick.so'

but as I'm using XAMPP, my extension dir( as I understand ) is /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626. So what should I do to make this working, I tried to put .so file in extensions dir and to add extension=imagick.so record in php.ini and to restart apache, unfortunately this didn't work. Forgot to mention, I'm using osX and XAMPP


回答1:


Did you install ImageMagick that is required to use imagick : ImageMagick for MacOSx




回答2:


I followed @Nodashi link: http://www.imagemagick.org/script/download.php#macosx

Here are steps you can to follow since I'm same Mac developer.

To install imagemagick:

brew install imagemagick

Successfully:

🍺  /usr/local/Cellar/imagemagick/7.0.10-0: 1,487 files, 24.3MB

To install ghostscript:

brew install ghostscript

Successfully:

🍺  /usr/local/Cellar/ghostscript/9.51_1: 671 files, 87.4MB

Find the magick:

which magick

Then:

/usr/local/bin/magick

Try to run it to test a image then you will find it works:

magick origin.jpg converted.png

So let's do it by PHP way

Create a new php file:

sudo touch magick.php

Enter the code which we will use the 'exec' function to run the magick program:

<?php 
shell_exec('magick origin.jpg converted_php.png');
?> 

After that we run it by:

sudo /Applications/XAMPP/xamppfiles/bin/php magick.php

Great, we can see there is a image file converted_php.png !!



来源:https://stackoverflow.com/questions/8138373/install-imagick-on-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!