How to Install Imagick and ImageMagick for XAMPP on a PC

If you want your PHP code to be able to use ImageMagick to edit images on a PC, you must download two pieces of software:

  • ImageMagick: an image editing program
  • Imagick: a PHP extension that allows PHP code to control the ImageMagick program

The Imagick extension adds classes and methods (that act like built-in classes and methods) you can use to work with images.

They allow your PHP code to control the ImageMagick software, opening, editing, and saving images.

Installing ImageMagick

1. Get required information

To install ImageMagick, you need to know if your version of Windows is 32-bit or 64-bit.

If you are not sure, go to the Windows Start menu and select Settings > System > About to open the About settings.

Under the heading Device specifications, the System type will indicate whether your version is 32-bit or 64-bit.

Screenshot of about page in the settings window.

2. Download the software

To download ImageMagick, go to the download page of http://imagemagick.org. If your version of Windows is:

  • 64-bit use the first version.
  • 32-bit use the version that has the description "Win32 dynamic at 16-bits-per-pixel component".

This will download an .exe file.

Download page of ImageMagick website

3. Install the software

Double click on the .exe file and follow the instructions in the installer.

During installation, check the box to add the application directory to your system path.

Screenshot of ImageMagick installation wizard

Installing Imagick

1. Get required information

To install imagick, you need to know three things, which you can find out from the first table of data that is generated by the phpinfo() function:

  • PHP Version
  • Operating system architecture (x64 or x86)
  • Whether "Thread Safety" is enabled

The phpinfo() function is used to show this information in the first example in the code download (in the examples for the Introduction).

Information shown when calling phpinfo function

2. Download the software

Click here to download the Imagick extension.

Find the most recent stable (not beta) version.

Click on the DLL link next to the windows logo for that version.

Screenshot of Imagick page on php.net.

This will bring up a page that lists different versions of the Imagick extension that you can download for Windows. Select the version that matches:

  • Your PHP version
  • Whether "Thread Safety" is enabled
  • Operating system architecture (x64 or x86)

When you click on the link for your version, a ZIP file will be downloaded.

Links to different verions of imagick

3. Install the software

Open the Imagick ZIP file and find the file called php_imagick.dll

Find your php\ext folder. The phpinfo() function will show you the path to this folder if you search for extension_dir

Typically for XAMPP, this folder is C:\xampp\php\ext

Copy the php_imagick.dll file into your php\ext folder.

Screenshot of the php_imagick.dll file being selected in Windows Explorer

Find your apache\bin folder.
When XAMPP installs Apache, it is usually here: C:\xampp\apache\bin

Copy the following files from the Imagick download, into the apache\bin folder:

  • All files with the prefix CORE_* and suffix .dll
  • All files with the prefix IM_MOD_* and suffix .dll

In total this is around 149 files.

Screenshot of mutliple .dll files being selected in Windows Explorer

4. Enable Imagick in php.ini

Having installed the Imagick extension, you must tell the PHP interpreter that it has been installed. To do this open your php.ini file.

Search for extension= and you will see lots of lines that start with this.

Add the following on a new line after the ones that are there:

Save the php.ini file, then restart XAMPP to apply the changes you made to the php.ini file.

php.ini file in text editor, with extensions showing

Checking ImageMagick is Installed

To check that ImageMagick is installed, you can type magick -version at the command prompt. If you see a message telling you the version, then you know it is installed.

Command prompt showing version of ImageMagick installed

Checking Imagick is Installed

To check that Imagick is installed, use the phpinfo() function and look for the heading imagick. If you find this heading followed by a table telling you information such as the version, supported classes, and image formats, then it is installed.

Results of phpinfo() function whoing imagick installed.