Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with Imagick and PHP

Tags:

php

imagick

My PHP script that uses Imagick gives me this error when I run it:

Fatal error: Class 'Imagick' not found in /var/www/vhosts/example.com/script.php on line 320

If I run php from SSH it gives me this warning:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/imagick.so' - /usr/lib/php/modules/imagick.so: undefined symbol: php_checkuid_ex in Unknown on line 0

The weird thing is that Imagick is always worked... I've tried to install it but it says that everything is already installed.

The lib is in the correct place:

# locate imagick.so
/usr/lib/php/modules/imagick.so

I've tried switching to the beta version of imagick because seems that Imagick has problems with the PHP version 5.4.2 but the problem is not solved:

pear config-set preferred_state beta
pecl upgrade imagick

When I try to upgrade it was failing on the configuration:

error: Unable to find MagickWand.h or magick-wand.h header ERROR: `/var/tmp/imagick/configure --with-imagick' failed

So I've created a symlink of magick-wand.h to /usr/include/ImageMagick/wand/MagickWand.h but now the errors is on the make:

/var/tmp/imagick/imagick_helpers.c:859: error: 'PaletteBilevelMatteType' undeclared (first use in this function)
/var/tmp/imagick/imagick_helpers.c:859: error: (Each undeclared identifier is reported only once
/var/tmp/imagick/imagick_helpers.c:859: error: for each function it appears in.)
make: *** [imagick_helpers.lo] Error 1
ERROR: `make' failed

How can I do?

like image 702
Fez Vrasta Avatar asked Dec 07 '22 04:12

Fez Vrasta


2 Answers

Ok I've solved this problem.

I've removed ImageMagick and ImageMagick-devel

yum remove ImageMagick
yum remove ImageMagick-devel

Then I've installed a more recent version from RPM:

cd /root
wget http://www.imagemagick.org/download/linux/CentOS/i386/ImageMagick-6.8.7-6.i386.rpm
wget http://www.imagemagick.org/download/linux/CentOS/i386/ImageMagick-devel-6.8.7-6.i386.rpm
rpm -Uvh ImageMagick-6.8.7-6.i386.rpm
rpm -Uvh --nodeps ImageMagick-devel-6.8.7-6.i386.rpm

note the --nodeps, needed because it was looking for a ImageMagick-libs that I can't find and seems not needed

then I've uninstalled Imagick

pecl uninstall imagick

And I've compiled it again using pecl

pecl install imagick

Everything is worked (with some warning but it works correctly after the installation).

This solution works on CentOS 5/6 x86, look for the libraries for your arch or distro if you have a different OS.

like image 85
Fez Vrasta Avatar answered Dec 17 '22 21:12

Fez Vrasta


I solved my issue with an uninstall then a re-install of 'imagick' extension using the pecl command

SSH into server as Root and type

pecl uninstall imagick

then...

pecl install imagick

Please note this is on a Centos 6.5 and running php 5.4.42 and ImageMagick 6.7.2-7

Worked a treat

like image 35
mikoop Avatar answered Dec 17 '22 19:12

mikoop