32

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

Dev DOS
  • 1,018
  • 4
  • 18
  • 45

6 Answers6

23

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.

Joe Okatch
  • 660
  • 5
  • 9
  • 4
    Part 3) is vital here - any other tutorial on the internet is saying that I just need paste those IM and CORE_ files into php folder but they need to be putted in apache folder as well. – Eryk Wróbel Oct 10 '18 at 12:42
  • 5
    Eryk is right, in my case on another site, it was written for part 3 to put all the DLL's in the PHP directory, not Apache's. After putting the DLL's in E:\wamp64\bin\apache\apache2.4.37\bin\ it was working perfectly fine! – that-ben Oct 30 '19 at 19:39
  • 1
    https://mlocati.github.io/articles/php-windows-imagick.html to get the latest.. But with Windows 10 Pro x64, Apache 2.4.41, PHP 7.4.0 x64 Thread Safety I had to put the CORE_RL_xxx and the IM_MOD_RL_xxx files in `C:\wamp64\bin\apache\apache2.4.41\bin\` as it was not working in the PHP directory... Or you should put them in a directory in your PATH variable. – zeuf Jun 11 '20 at 16:42
  • HI GUYS, this thread saved me! Does anyone know why it should be placed in the Apache folder instead of the PHP one? – Darrell Ng Jul 04 '22 at 02:16
  • Didn't worked at first. Problem was that at #5 i copied dll and "other dlls" to same folder "ext". Solution is to copy as it says :D – Roman Losev Aug 08 '23 at 11:45
21
  • 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

Amadu Bah
  • 2,919
  • 28
  • 27
  • 12
    OP is on Windows, as indicated by the many Windows-specific references in his question (WAMP, Windows-style paths, .dll files, .exe file, etc.). – nanny Nov 10 '14 at 17:47
  • You solved it and helped google, doesn't matter what OP wanted but what he asked lol – Janaka R Rajapaksha Oct 20 '21 at 17:01
1

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.

Dev DOS
  • 1,018
  • 4
  • 18
  • 45
  • 1
    I am not sure about the version I used, but try with this link:`http://www.peewit.fr/imagick/` and install the appropriate zip ,inside the zip you will find the .dll file you have to extract it to (in my example): `C:\wamp\bin\php\php5.4.16\ext\` and keep going with the steps I wrote in the main question. If you still have the error I may send you my imagick.dll file. – Dev DOS May 05 '15 at 15:46
  • 1
    It is very hard to install it in the local server – Sai Deepak May 06 '15 at 05:39
  • 1
    Then you have to work on unix environment it is soo easy to install imagick. you will not have to do any additional configurations. Good luck. – Dev DOS May 07 '15 at 15:27
  • try to follow this post. it contains details about how to install imagick on windows: `http://stackoverflow.com/questions/27193631/installing-imagick-for-php-5-6-3-and-apache-2-4-on-win-7` and `http://refreshless.com/blog/imagick-pecl-imagemagick-windows/` – Dev DOS Aug 27 '15 at 13:40
  • This should not be the accepted answer in 2019. Latest version of Imagick works perfectly fine, follow these steps instead, it works great. https://stackoverflow.com/a/52731379/8027363 – that-ben Oct 30 '19 at 19:40
0

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

earnest
  • 261
  • 2
  • 4
  • 9
0

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.

Paulo Amaral
  • 747
  • 1
  • 5
  • 24
0

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.

David Hash
  • 87
  • 1
  • 8