
Here’s a step-by-step guide on how to install ImageMagick PHP extension in XAMPP on Windows:
Table of Contents
Download the correct Imagick DLL
Go to the PECL Imagick extension page
Download the version that matches:
- Your PHP version (e.g. PHP 8.2, 8.1, etc.)
- Your PHP architecture (x64 or x86 — check using
phpinfo()orphp -i) - Thread safety: TS (Thread Safe) if you’re using Apache with XAMPP (most common), or NTS (Non-Thread Safe) if you’re using FastCGI
Example file: php_imagick-3.8.0-8.2-ts-vs16-x64.zip
Copy the DLL to XAMPP
- Extract the downloaded file “
php_imagick-3.8.0-8.2-ts-vs16-x64.zip“ - Extract
php_imagick.dlland save it to the ext directory of your PHP installation - Copy this file to your XAMPP
php\extdirectory:
C:\xampp\php\ext\php_imagick.dllCode language: CSS (css)
Also extract from php_imagick-….zip the other DLL files (they may start with CORE_RL, FILTER, IM_MOD_RL, or ImageMagickObject depending on the version), and save them to the PHP root directory (where you have php.exe), or to a directory in your PATH variable
C:\xampp\php\
Update php.ini
Open your php.ini file:
C:\xampp\php\php.iniCode language: CSS (css)
Add the following line at the end of the file:
extension=imagick
Save the file
Verify Installation
- Create a PHP file, for example
phpinfo.php: phpCopyEdit<?php phpinfo(); ?> - Open this in your browser:
http://localhost/phpinfo.php - Look for imagick section — if you see it, the extension is installed correctly.

To test if the extension works, you can run this PHP code:
Here’s a simple test script to verify if ImageMagick is installed and working properly in your XAMPP setup:
<?php
try {
// Check if Imagick class exists
if (!class_exists('Imagick')) {
die("Imagick class not found. Extension may not be installed.");
}
// Create a new Imagick object
$image = new Imagick();
// Create a simple 200x200 red image
$image->newImage(200, 200, new ImagickPixel('red'));
$image->setImageFormat('png');
// Add some text
$draw = new ImagickDraw();
$draw->setFillColor(new ImagickPixel('white'));
$draw->setFontSize(20);
$draw->annotation(20, 100, 'ImageMagick Works!');
$image->drawImage($draw);
// Set the appropriate header and output the image
header('Content-Type: image/png');
echo $image;
// Destroy the image to free memory
$image->destroy();
} catch (Exception $e) {
// Display any errors
header('Content-Type: text/plain');
echo "ImageMagick Test Failed:\n";
echo "Error: " . $e->getMessage() . "\n";
echo "Check if:\n";
echo "1. ImageMagick is installed on your system\n";
echo "2. PHP Imagick extension is properly installed\n";
echo "3. The correct paths are set in your environment variables\n";
}
?>Code language: HTML, XML (xml)
How to use this test script:
- Save this code as
test_imagick.phpin your XAMPPhtdocsfolder - Access it through your browser:
http://localhost/test_imagick.php
Expected results:
- If ImageMagick is working, you’ll see a red square with white text saying “ImageMagick Works!”

- If there are problems, you’ll see an error message explaining what might be wrong
This script tests:
- The existence of the Imagick class
- Basic image creation capabilities
- Text rendering functionality
- Proper output of the image
If this works, you can be confident that ImageMagick is properly installed and functional in your XAMPP environment.

