9
votes

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

2

2 Answers

0
votes

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

0
votes

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