I already have ImageMagick installed in my machine and I tried to install the Imagick extension for PHP but I was stuck with strange errors. I have spent couple of hours today to figure out what I did wrong and Why I cant build that extension. Finally I’ve figured out that I must install ImageMagick from source first to build that extension. Heres how to
1. You have to install ImageMagick from source and Its a Must. Otherwise the extension for PHP wont compile. It will show you a strange error like magic_wand.h not found.
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar zxf ImageMagick.tar.gz
cd ImageMagick-6.3.8
./configure
sudo make
sudo make install
2. Now download the Imagick extension source from pecl.php.net – I tried imagick-2.1.0RC3
wget http://pecl.php.net/get/imagick-2.1.0RC3.tgz
tar zxf imagick-2.1.0RC3.tgz
cd imagick-2.1.0RC3
phpize && ./configure
sudo make
sudo make install
This will make compile imagick source and build imagick.so – In my machine, I found imagick.so in the following directory
/usr/lib/php5/20060613+lfs
3. Now add “extension=imagick.so” in your php.ini (You may need to write the full path of imagick.so based on your configuration)
4. Restart your web server and thats it
Look at the php ini – you will see something like below (Click to enlarge)
THANKS!
I would have found a solution to this myself eventually, but now I don’t have to. Any idea why the Ubuntu packages are broken?
Probably version conflicts.. ubuntu comes with imagemagic 6.2.x in edgy and hardy (for now). You have 6.3.x.
But installing the official php5-package for imagick extension worked just fine for me, it is however an older version: (This is hardy, edgy is similar, just an older verson.. 2.0.0-alpha)
~$ sudo apt-get install php5-imagick
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut
Reading state information… Fertig
The following packages were automatically installed and are no longer required:
libfftw3-3
Verwenden Sie »apt-get autoremove«, um sie zu entfernen.
Die folgenden NEUEN Pakete werden installiert:
php5-imagick
0 aktualisiert, 1 neu installiert, 0 zu entfernen und 0 nicht aktualisiert.
Es müssen 84.0kB Archive geholt werden.
After this operation, 397kB of additional disk space will be used.
Hole:1 http://archive.ubuntu.com hardy/universe php5-imagick 2.0.1-1 [84.0kB]
Es wurden 84.0kB in 0s geholt (252kB/s)
Wähle vormals abgewähltes Paket php5-imagick.
(Lese Datenbank … 155696 Dateien und Verzeichnisse sind derzeit installiert.)
Entpacke php5-imagick (aus …/php5-imagick_2.0.1-1_amd64.deb) …
Richte php5-imagick ein (2.0.1-1) …
Creating config file /etc/php5/conf.d/imagick.ini with new version
$ php -i | grep imagick
additional .ini files parsed => /etc/php5/cli/conf.d/imagick.ini,
imagick
imagick module => enabled
imagick module version => 2.0.1
imagick classes => Imagick, ImagickDraw, ImagickPixel
The better way to install the pecl package is:
$ sudo pecl upgrade imagick
or
$ sudo pecl install imagick
Just like using PEAR, you can choose stable, beta or alpha packages.
I had a similar problem with Ubuntu’s php5-imagick package, uninstalled and grabbed the PECL package, which works well and gives me access to all the latest methods.
I found some problems with restarting Apache after upgrading Imagick:
$ sudo apache2ctl configtest
Syntax OK
$ sudo apache2ctl restart
$ ps -ef | grep apache
james 12282 9338 0 09:31 pts/4 00:00:00 grep apache
$ sudo apache2ctl start
$ ps -ef | grep apache
root 12328 1 6 09:31 ? 00:00:00 /usr/sbin/apache2 -k start
Here is what apache error log says for the above, snipped for brevity:
[Thu Feb 07 09:31:12 2008] [notice] SIGHUP received. Attempting to restart
[Thu Feb 07 09:31:12 2008] [notice] seg fault or similar nasty error detected in the parent process
[Thu Feb 07 09:31:23 2008] [warn] pid file /var/run/apache2.pid overwritten — Unclean shutdown of previous Apache run?
[Thu Feb 07 09:31:23 2008] [notice] Apache/2.2.4 (Ubuntu) configured — resuming normal operations
You need to install the package libmagick9-dev. This package contains the necessary headers to compile Imagick.
@Mikko
I tried installing graphicsmagick-libmagick-dev-compat but libmagick9-dev, because afaik Wand_config was available to both these packages. It installed suucessfully but when I tried to compile Imagick extension, it ends up with the same error magic_wand.h not found.
Thanks for the info.
@James
Until I had built ImageMagick from source, “pecl install imagick” ended up with same error.
You could probably just install the dev package of image magick via a repository…
GraphicsMagick backend is no longer supported. libmagick9-dev also provides the magick-wand.h header that is required to compile Imagick.
Fantastic post! Thanks very much.
Really this POST helped me a lot. I am using Redhat version , ok i will try to use this tips to implement in my server and let see it works or not.
Thanks very much 🙂
Thanks you, your guide help me upgraded ImageMagick and imagick pretty straightforward.
Hey thanks man!
After struggeling with the install for hours I finally made it!
HELLO WORLD 🙂
PHP Warning: PHP Startup: Unable to load dynamic library ‘…/imagick.so’ – …/imagick.so: undefined symbol: XStringListToTextProperty in Unknown on line 0 la soulucion en suse fue la instalacion de rc2e
luego el proceso nomarl de instalcion
pecl install imagick
…
cuando pida la ruta coloca la ruta de extencion de php
/usr/php5/extencion/
….
en la carpeta de imagick ejecuta lo siguiente
….
#phpize
#./configure
….
service apache2 stop
service apache2 start
en el php.ini
extencion=imagick.so
Hi! (sorry my english 🙂
I have problem with imagick install.
I have done this:
– install libmagick9, libmagic9-dev
– download ImageMagick 6.5,Imagick-2.3
-I have compiled ImageMagic and install
– I have compiled Imagick and install
– add .so to my php.ini file
I see this in phpinfo() output:
imagick module enabled
imagick module version 2.3.0
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
etc.
It seems to be ok, but when I try call a imageick function i get this error message:
Class ‘Imagick’ not found in …
What can I do?
Thx,
cyrip
hi,
your technique was helpful to me and it worked.
previously i was trying to do
pecl install imagick
but it was not doing the needful.
thanks to you for writing this technique here.
Farrukh.