Imagick php windows

I spent many hours trying to make Imagick work, finally I got it.

My installation instructions

  1. Install WAMP 32bit (even if you running 64bit system you must use 32bit version of WAMP)
  2. Install ImageMagick to C:/imagemagick, use this file: https://www.dropbox.com/s/i2mhrhd7sp0ilzk/ImageMagick-6.8.0-3-Q16-windows-dll.exe
  3. Put DLL with Imagick into extension folder of PHP, e.g. D:\wamp32\bin\php\php5.4.16\ext, I used this file: https://www.dropbox.com/s/ayankf850l08rm2/php_imagick.dll
  4. In php.ini put line "SetEnv MAGICK_HOME C:/imagemagick" without quotes
  5. Better restart PC

I use Wamp 2.4, PHP 5.4.16, Apache 2.4.4, ImageMagick 6.8.0-3 2012-10-24 Q16, Imagick 3.1.0RC2 - all 32bit, OS Win8 64bit

Now it should work and you should see Imagick extension loaded in phpinfo.

I tried a lot of versions of ImageMagick, but newer versions didn't work, 6.8.0-3-Q16-windows-dll works fine.

Symfony2

In Symfony2 use Imagick like this:

$im = new \Imagick('image.jpg');

After trying many solutions, none seemed to work.

I managed to install it on Windows 10 64-bit, Apache 2.4 and PHP 5.6, but I think it should work for all versions.

Hopefully you will have no problem installing Imagick for PHP.


Step 1) Gather information

First of all you should gather some information of your PHP environment.

You can easily see your PHP information with the function phpinfo()

The information you need:

  • Architecture: x86(32-bit) or x64(64-bit)
  • PHP-version: you can find this in the header of the phpinfo() output.
  • PHP Extension Build: This string contains 2 important parts:
    • NTS or TS
    • VCx (like VC11)
  • Loaded Configuration File: the path to your used php.ini file.

Step 2) Download Binary

You can download the binary from the official site of ImageMagick. I recommend you to read the small introduction under the "Windows Binary Release" to be certain which "bits-per-pixel" to choose from(8 or 16). Downloading the latest version should be just fine.

Make sure this binary is the same architecture as your PHP architecture that you have gathered in step 1.

Step 3) Install Binary

Install the binary to your phpx.x.xx\bin file. For example: C:\wamp64\bin\php\php5.6.16\bin. (This can be any folder, but for the convenience I put in here)

Make sure "Add application directory to your system path" is checked. Should be checked by default though.

Step 4) Download PHP extension

The DLL PHP extension is available through the windows pecl php site

Again, you can just click the latest version.

Next of, choose the right version based on the gathered information.
For example: php_imagick-3.4.1-5.6-nts-vc11-x64.zip

This can be stripped into components:

  • php_imagick-3.4.1 - This is the php imagick extension with the version. This is not important.
  • 5.6 - This is your PHP version and should be equal to the PHP-version you are using, which you have determed in step 1.
  • NTS - This should be equal to the information of your PHP Extension Build that you have gathered in step 1.
  • VC11 - This should also be equal to the information of your PHP Extension Build that you have gathered in step 1.
  • x64 - This the architecture of the extension and should be equal to your PHP architecture that you have gathered in step 1.

Step 5) Extract PHP Extension

After you have downloaded the file, you should open the .zip file and look for a file named: php_imagick.dll. Extract this file to phpx.x.xx\ext.

Make sure the .dll file is fully accessable by you. Sometimes you need to explicity unblock the file.

Unblock file

Step 6) Activate PHP extension

To activate the extension in PHP, you should state in your php.ini file that you want to use this extension. You have gathered the path to your used php.ini file in step 1.

Add the line extension=php_imagick.dll to your php.ini

PHP.ini Imagick line

Step 7) Restart your PC

Just to make sure, restart your PC so all Environment Paths will be correctly loaded.


This should install Imagick correctly with the latest versions and the right architecture. Imagick should also be listed in phpinfo() with the appropriate "ImageMagick supported formats" (Just make sure it is not empty).


I'm quite sure this is to do with not having the module loaded correctly or the .dll being placed in a improper location.

You can use PHP's internal function extension_loaded() to check prior to using the class,

<?php
  /**
   * 
  **/
  if (!extension_loaded('Imagick')) {
        //Load some error.
  }
?>

That's a method you can check if the module is even being reconsigned by PHP at all. PHP also provides a function to view your current extensions get_loaded_extensions():

<?php 
   /**
    *   Get an Array of current
    *   PHP extensions for debugging
   **/
   print_r( get_loaded_extensions() );
?>

Make sure you do:

  • Check your correct extension library folder location within your phpinfo()
  • Perform a hard restart of your xmapp/wamp server.
  • If you're on PHP 5.4 or upwards (Like yourself!), see site below for the updated binaries

After researching too, Imagick does seem to have trouble with PHP 5.3 or upwards; Download new DLL's from this site below (Unofficial):

http://www.peewit.fr/imagick/

Also found other StackOverFlow Articles that have the same problem:

Stackoverflow: Trying to get imagick running on PHP 5.4.3 at Windows x64

Alternatively you're able to use the GD extension to more or less accomplish some of the same functions you require. I do believe GD is a more widely supported module/extension in more recent versions of PHP.

Tags:

Php

Imagick