Home  >  Q&A  >  body text

Fatal error: Class 'imagick' not found

I'm trying to install the imagemagic php extension under WampServer 2.

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

When I try to test 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 did I do wrong? I'm using win7 32 bit, php 5-4-16 and apache2

P粉296080076P粉296080076342 days ago613

reply all(2)I'll reply

  • P粉716228245

    P粉7162282452023-10-18 10:09:48

    Your library version may be misaligned.

    This is how I solved the problem

    It's really hard for me to answer all these questions. Looking back, I realize that most of them were correct, it's just that they left out some very finevital details.

    1). First and foremost, before you start downloading any library or DLL, you need to look for these three very important parameters, starting with php_info. p>

    Run PHP_Info and check:

    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). Extract all DLLs from the unzipped bin subfolder and copy them to the Apache bin directory. It's a bunch of CORE_RL_.dll and IM_MOD_RL_.dll and 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 a zip link or just a DLL link. I prefer DLL linking. In my case, I chose the latest version, 3.4.3. Then I went to https://pecl.php.net/package/imagick/ 3.4.3/Windows. Here again we must choose carefully

    1. My PHP version is PHP 5.6
    2. Thread safety is enabled
    3. PHP runs on the architecture x86
    4. So I chose 5.6 Thread Safe (TS) x86

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

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

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

    Extra Tip: You may need to download the Visual C 14 Runtime. Via this link https://support. microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloadsI chose the latest version.

    reply
    0
  • P粉964682904

    P粉9646829042023-10-18 10:09:42

    The only way I got it to work was using an older version of imagick: php_imagick-3.2.0b1-5.4-nts-vc9-x86.

    reply
    0
  • Cancelreply