28
votes

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

6
You provided whole tutorial here, thanks man, your Q is actually an answer for most of us! - Raza Ahmed
please please tell me how and where did you download ImageMagick? - Shirin Abdolahi
to my knowledge imagik comes with wamp you might wanna see if its enabled. - astroanu
you may want to include files manually.. I had similar issue in past and it ended up the class was not being called because of relative paths. - Invincible

6 Answers

18
votes
  • 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

12
votes

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.

1
votes

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.

0
votes

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

0
votes

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.

0
votes

I was able to get WAMPSERVER 3.2.3 to work. It turns out that there are several php.ini files. I had to change the one in the directory for the Apache server to get ImageMagicK to work with LocalHost.

I added the extension to the php.ini file in the apachexx.xx.xx\bin directory

extension=imagick

I had paths which still pointed to the PHP directories and that worked for me.