ImageMagick on Windows

Introduction(Edit)

I could say the worst about it. Already running Apache on Windows is not the easiest to start with. Willing to run Apache, PHP, ImageMagick with Windows, all working, can appear to only rely on luck...

I've just spent a few days dealing with it. I had a running config with PHP 5.4 and was willing to update to PHP 5.5. As my initial config had already been a pain, I ended up facing the same problems, again.

So now I took notes, and I will write a bit about it, at first in my own interest, as I really would like to leave it behind from now on. If it can help, if you have more information about it, feel free.

The difficulty is to get all the corresponding version, compilers, architectures, extensions, and so on. So we will check the PHP installation, assuming you run Apache. If you don't, the process remain the same, just pay attention to download NTS version for Imagick, as the TS is made for Apache (if you don't get it now, don't worry, it will be deepened when required).

Requirements(Edit)

For a few now, solutions have been created to addresse the Apache difficulties on Windows, packages such as WAMP, WAPP, and so on offer a good start. It's when you need some tweaks that troubles appear.

In order to get started, you will need a running Apache/PHP config, as I won't explain that here.

Getting started(Edit)

The first step is to have a look into your PHP install. Create a new script with the following content, and access it (so put it into your htdocs or www folder):

<?php
    phpinfo();
?>

This will give you a good overall of your config. Directly at the top of the document are the information we need to have:

From there, you obtain the PHP version number, the architecture (x86/x64), the compiler (VC9/VC11), information we will use later on.

Serious sh*t(Edit)

Once we now what we run, we can see a bit better what is required. In example from the picture, I will need the Imagick version for PHP 5.5, x86, VC11. The PHP architecture can be different from your computer's one. In example, I run a 64 bits Windows, but still, PHP is not.

Binaries for ImageMagick can be downloaded from [http://ftp.sunet.se/pub/multimedia/graphics/ImageMagick/binaries/]. Keep in mind to download the package corresponding to your needs (I used the ImageMagick-6.7.7-5-Q16-windows-dll , still x86).

Make sure ImageMagick has been added to the PATH, otherwise the extension will not find it. Restart to apply changes. Once done, you should be able to type ImageMagick commands into the command line prompt (i.e convert).

In order to enable ImageMagick with Apache and PHP, we need to download the Imagick DLL from [http://www.peewit.fr/imagick/]. Here you need to choose wisely :

  • Find the corresponding PHP version packages
  • Check to have the same compiler version and architecture as your PHP version.
  • Choose between Thread-Safe and Non Thread-Safe (TS / NTS).
    • TS goes for Apache/Nginx servers
    • NTS goes for IIS servers

Once downloaded (I picked up php_imagick-3.2.0RC1-5.5-ts-vc11-x86.zip), you need to copy the contained DLL into the php/extensions folder (or php/ext, whatever is your PHP extensions folder). And in order to make it effective, you need to add the following line into your php.ini file (if you don't know where to find it, it is given b the phpinfo script as well, just find the "Loaded Configuration File" row).

extension=php_imagick.dll

After modyfing the php.ini file, restart your Apache server. If you refresh the phpinfo page, you should be able to obtain results to a search for "imagick". If not, try to start PHP in a command line with "php -v" argument. It should display you a more precise error message. If not, add

display_startup_errors = On

into your php.ini file and restart the server before to try again. You mostly have 3 options:

  • php5.dll is not found => you picked the IIS (NTS instead of TS) version.
  • invalid entry point ... => take a lower version of ImageMagick and try again?
  • Not a win32 valid app ... => download the x86 version, not the x64

Conclusion(Edit)

A bit of luck, a lot of details. Once all that in mind, it should make it easier for you to find a working setup. Thanks to [http://stackoverflow.com/questions/21055786/running-imagemagick-on-xampp-1-8-3-with-windows-7/21084043#21084043], as it has given me directly the working setup:


    *OS: Windows 7 64 Bit
    *PHP: 5.5.6
    *XAMPP: 1.8.3
    *Compiler: MSVC11
    *Architecture: x86
    *ImageMagick: ImageMagick-6.7.7-5-Q16-windows-dll
    *Imagick DLL: PHP5.5.x version