Fatal error: Class 'imagick' not found

╄→гoц情女王★ 提交于 2019-12-08 14:35:43

问题


I am trying to install imagemagic php extension under WampServer 2.

  • I've downloaded and installed ImageMagick . I've chosen ImageMagick-6.8.8-10-Q16-x86-dll.exe

  • I've downloaded the php extension.

  • I've moved the dll extension I just downloaded to C:\wamp\bin\php\php5.4.16\ext\

  • I've altered php.ini (accessed it through wamp tray icon > right-click > PHP > php.ini) and added "extension=php_imagick.dll", without the quotes, to the extensions lists.

  • I restarted Apache. Not noticing the extension displayed on the PHP extensions list from the tray icon, I restarted the wampserver. ImageMagick extensions now shows enabled on the list.

However, I cannot use it. Doing a quick test returns "Fatal error: Class 'Imagick' not found". In the phpinfo() shows only that the imagemagick has been added to env variables.

when I try to test the imagick :

$im = new imagick( 'test.jpg' );
// resize by 200 width and keep the ratio
$im->thumbnailImage( 200, 0);
 // write to disk
$im->writeImage( 'test_thumbnail.jpg' );

I get the error:Fatal error: Class 'imagick' not found What am I doing wrong? I'm working with win7 32 bit, phph 5-4-16 and apache2


回答1:


  • Try: php -m | grep imagick.
  • If the result is empty do: sudo apt-get remove --purge php5-imagick && sudo apt-get install php5-imagick

Regards




回答2:


You might be having mis-aligned library versions.

Here's how I solved it

I had really struggled with all these answers. Looking back I realised most of them are correct except they leave out some very fine details that are crucial.

1). First and foremost, before you start downloading any libraries or DLLs you want to start with your php_info to find out these three very important parameters.

Run the PHP_Info and check:

  1. Architecture : x86 or x64. Your computer might be x64 but your php is running on x86 so don't assume
  2. Thread Safety : yes or no. Also very important.
  3. Your PHP Version

2). Download ImageMagick from: https://windows.php.net/downloads/pecl/deps/. My computer is x64 but my php is running x86 so I downloaded ImageMagick-7.0.--vc*-x86.zip

3). Unzip and copy all DLLs from the unzipped bin subfolder to the Apache bin directory. It's a bunch of CORE_RL_.dll and IM_MOD_RL_.dll plus a few other DLLs. In my case, [zippeddownload]/bin/* ->copied to -> C:\Xampp\apache\bin

4). Go to http://pecl.php.net/package/imagick. You can select the zip link or just the DLL link. I prefer the DLL link. In my case I selected latest version 3.4.3. Which then took me to https://pecl.php.net/package/imagick/3.4.3/windows. Here we have to make another careful choice

  1. My php version is PHP 5.6
  2. Thread Safety is enabled
  3. Architecture php is running on is x86
  4. So I took 5.6 Thread Safe (TS) x86

5). Unzip and copy "php_imagick.dll" to the php ext folder. And all other DLL files to the php folder

6). Using an editor open php.ini. Search for "extension=" and add this line extension=php_imagick.dll as one of them.

7). Restart Xampp/Wamp or just restart Apache and run PHP_INFO again. Imagick should display. If you still can't see it refer to this link http://php.net/manual/en/imagick.setup.php#119084

Bonus tip: You might need to download visual c++ 14 runtime. From this link https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads I chose the latest version.




回答3:


The only way that I make it works is by using an older version of imagick:php_imagick-3.2.0b1-5.4-nts-vc9-x86.




回答4:


do a <?php phpinfo(); ?> in any page. This will show all the services running on the service. If it is running then it will show you in which directory.

If you are using WHM panel you might have to install imageMagick there




回答5:


Did you try using the proper casing for the class, starting with capital "i"?

$im = new Imagick( 'test.jpg' );

In php, class and files names and not case-sensitive, but classloaders are.




回答6:


apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz
cd imagick-3.4.0
phpize
./configure
make install
rm -rf /tmp/imagick-3.4.0*
echo extension=imagick.so >> /etc/php/7.0/cli/php.ini
echo extension=imagick.so >> /etc/php/7.0/fpm/php.ini
service php7.0-fpm restart
service nginx restart

from Install Imagick 3.4.0 on PHP 7



来源:https://stackoverflow.com/questions/23026181/fatal-error-class-imagick-not-found

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