PHP 101
  • Home
  • Deploy
  • How-to
  • Tutorial
No Result
View All Result
PHP 101
  • Home
  • Deploy
  • How-to
  • Tutorial
No Result
View All Result
PHP 101
No Result
View All Result
Home Tutorial

How to install ImageMagick on Windows

In-depth tutorial on how to install ImageMagick on Windows operating system and get it working properly with PHP.

September 9, 2022
Reading Time: 5 mins read
PHP101.Net - Tutorial - Install ImageMagick on Windows

PHP101.Net - Tutorial - Install ImageMagick on Windows

Share on FacebookShare on Twitter

Table of Contents

    • Prerequisites
    • Windows System Requirements
    • 1. Download ImageMagick Windows package
    • 2. Install ImageMagick on Windows
    • Verify ImageMagick installation
    • 3. Download ImageMagick PHP extension
    • 4. Install ImageMagick PHP extension
    • 5. Verify PHP ImageMagick extension working
    • Final thoughts
    • You might also like
    • References

ImageMagick is a powerful free and open-source software for image manipulation. It is fully cross-platform and mainly used by many websites for processing images. ImageMagick has a PHP extension that makes it easy to use, powerful and is usually preferred more than PHP GD extension.

This tutorial will guide you on how to install ImageMagick on Windows operating system and make it works properly as a PHP extension.

Note: This article is solely focused on installing and getting ImageMagick to work with PHP in Windows system, and will not explain non-related PHP parts into details.

Tutorial StartsPrerequisites

This article assumes that you already got a webserver running properly with PHP installed and enabled.

Windows System Requirements

As mentioned on official ImageMagick download page, the software is fully compatible with most Windows version, from Windows Server 2008 R2 (x64) to Windows 11. Unless you wanted to install it on ancient versions as Windows 95 (!), we are good to go.

A single core Windows computer with minimum 512MB of RAM should be suffice to run ImageMagick, although having more will provide better performance. Both 32-bit, 64-bit and ARM64 system is compatible.

1. Download ImageMagick Windows package

Go to the Official ImageMagick download page and scroll to the Windows Binary Release section. You will see a table with plenty of versions to download.

To keep things simple, choose the recommended version that is listed at the first of the list to download:

PHP101.Net - Tutorial - Install ImageMagick on Windows
Default recommended ImageMagick version for Windows

Otherwise, in case you wanted more customized version for your system, choose version that has the filename that suits your system to download:

  • Choose dynamic version with dll in filename, which is more preferred for using PHP to work with.
  • Version with Q8 is for 8 bits-per-pixel image processing, while Q16 provides 16 bits-per-pixel.
    The latter uses more resources, but will have much better image precision. Usually, with 1GB+ memory, it’s fine to use Q16 version.
  • Version with HDRI will enable High Dynamic Range Imaging processing, and is recommended.
  • For 64-bit system, choose the version with x64 in filename.
    For 32-bit, choose x32, and for ARM64, choose arm64.
  • Choose installer version with exe extension, which will setup and configure the paths automatically for you (again, let’s keep things simple). If you choose portable version, you will have to set the environment paths manually.

2. Install ImageMagick on Windows

After downloaded the preferred version (which is installer version having exe extension), run the file to start the installation.

Accept the license and information:

PHP101.Net - Tutorial - Install ImageMagick on Windows
Click Next to accept the license and information of the installation.

Ensure “Add application directory to your system path” is checked, so the installer can configure the environment paths for you, making things easier. If you want to process FFmpeg video, check the Install FFmpeg option, else it can be left unchecked.

PHP101.Net - Tutorial - Install ImageMagick on Windows
Check this option so the Environment Variables will be added automatically.

Click Install on the next screen, and ImageMagick will be installed. You can view the index.html introduction page or uncheck it and finish the installation.

PHP101.Net - Tutorial - Install ImageMagick on Windows

By default, it is installed on C:\Program Files\ImageMagick-{version}, which contains all of the Windows executable files that are ready to use with PHP.

PHP101.Net - Tutorial - Install ImageMagick on Windows
ImageMagick default installation path in Windows.

Verify ImageMagick installation

To verify if ImageMagick is installed on Windows, open a terminal console as cmd and run the command:

magick -version

On successful installation, the command will return with ImageMagick version, and built in modules:

PHP101.Net - Tutorial - Install ImageMagick on Windows
Successful ImageMagick installation on Windows.

Now we have ImageMagick on Windows installed, in the next steps, we will also get the ImageMagick PHP extension installed for them to work together.

3. Download ImageMagick PHP extension

Depends on your installed PHP version, the recommended version for ImageMagick PHP extension will be different accordingly.

First, head to the Official Windows PHP PECL extension for ImageMagick release page. Then, choose the download according to the installed PHP version, or else the extension will not work properly.

  • For PHP 7.4 to 8.1, choose the 3.7.0 version of the extension.
  • For PHP 7.3, choose 3.6.0 extension version.
  • For PHP 7.1 to 7.2, choose the 3.4.4 extension version.
  • For PHP 7.0 and below, choose the 3.4.3 extension version.
  • Any extension version below 3.4.3 is not recommended.

For example, to choose version 3.7.0 of the extension, click the 3.7.0 version URL:

PHP101.Net - Tutorial - Install ImageMagick on Windows
Choose a version to download PHP ImageMagick extension. Here is version 3.7.0.

Then, pick the recommended download for your system and PHP version.

  • For non-thread-safe version, choose nts filename, for thread-safe version, choose ts version.
    Quick recommendation: If you use XAMPP or Laragon to host the webserver, choose nts version.
    If you use IIS for webserver, choose ts version.
  • For 32-bit version, choose x86 filename, for 64-bit version, choose x64 filename.
  • It’s recommended to pick the higher Visual Studio compiled version, which is vs16.

For example, the recommended extension download for for PHP 8.1, 64-bit system, non-thread-safe version:

PHP101.Net - Tutorial - Install ImageMagick on Windows
Widnwos PHP ImageMagick extension 3.7.0 for PHP 8.1, non-thread-safe

After downloading, extract the package to a folder. We are ready to install the ImageMagick extension to the existing PHP installation.

4. Install ImageMagick PHP extension

After extracting the downloaded extension zip file, we can install them to our PHP installation.

First, copy all of the .dll file in the extracted folder to the PHP installation folder where php.exe is located.

For example, with XAMPP (php folder in [XAMPP folder]/php):

PHP101.Net - Tutorial - Install ImageMagick on Windows
Copy all .dll files from extracted folder to XAMPP/php folder

For example, with Laragon (php folder in [Laragon folder]/bin/php/[php version folder]:

PHP101.Net - Tutorial - Install ImageMagick on Windows
Copy all .dll files from extracted folder to Laragon/bin/php folder

Then, copy/move the php_imagick.dll file to the ext folder of PHP installation folder:

PHP101.Net - Tutorial - Install ImageMagick on Windows
Copy php_imagick.dll file to PHP ext folder.

The installation is now finished. Remember to restart the webserver for it to take effect.

5. Verify PHP ImageMagick extension working

To verify that the PHP ImageMagick extension is working properly in Windows, we have multiple methods. The easiest way is to view PHPInfo and check whether the ImageMagick PHP extension is displayed.

Create a php file with the following lines:

<?php
// phpinfo.php file

phpinfo();

Open the file on your browser, and search for imagick. If this section exists, the PHP extension for ImageMagick on Windows is fully installed and should be working properly (with the condition that ImageMagick package is also installed):

PHP101.Net - Tutorial - Install ImageMagick on Windows
PHP extension for ImageMagick on Windows is installed and loaded properly.

The tutorial is now over.

Final thoughts

We hope this detailed tutorial can help you to get ImageMagick on Windows and its PHP extension to be installed and working properly on Windows operating system. There will be other tutorials and how-to articles on using ImageMagick properly and efficiently, as it is a very powerful yet simple to use in PHP for manipulating images.

You might also like

  • How to display image from file using PHP
  • How to convert image to base64 using PHP

References

  • ImageMagick official website
  • PHP.net Official Documentation – ImageMagick

 

Tags: imagemagick on windowsimagemagick windowsinstall imagemagickinstall imagemagick on windowslaragonxampp
Previous Post

How to display image from file using PHP

Next Post

How to remove empty array elements using PHP

Related Posts

PHP101.Net - Tutorial - Change Laragon PHP version on Windows

How to change Laragon PHP version on Windows

September 21, 2022
PHP101.net - Tutorial - Install Composer on Linux

How to install Composer on Linux

March 8, 2022
Next Post
PHP101.Net - How to remove empty array elements using PHP

How to remove empty array elements using PHP

We deliver free and helpful resources for learning
and using PHP programming language.

About
Contact Us
Privacy Policy
Main Sections

Home
Deploy
How-to
Tutorial
You might be interested in...

How to install Composer on Windows

How to get user IP address using PHP

How to detect visitors by country using PHP & GeoIP

3 ways to get PHP memory limit value

How to display image from file using PHP

© 2022 PHP101.Net - Helpful PHP Tutorials, How-to, Tips and Tricks for everyone.

No Result
View All Result
  • Home
  • Deploy
  • How-to
  • Tutorial

© 2022 PHP101.Net - Helpful PHP Tutorials, How-to, Tips and Tricks for everyone. | Privacy Policy

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.