Php imagemagick windows install

Installation

This » PECL extension is not bundled with PHP.

Information for installing this PECL extension may be
found in the manual chapter titled Installation
of PECL extensions. Additional information such as new releases,
downloads, source files, maintainer information, and a CHANGELOG, can be
located here:
» https://pecl.php.net/package/imagick.

Note:
The official name of this extension is imagick.

Windows users can download prebuilt DLL from the » PECL website.
These packages already contain the extension DLL (php_imagick.dll)
which needs to be put into the extension_dir.
They also contain the ImageMagick DLLs, which need to be put somewhere in the PATH.
As of Imagick 3.6.0, they also contain XML configuration files in config;
to use these instead of the built-in defaults, they need to put into %USERPROFILE%/.config/ImageMagick,
or alternatively in the path given by the environment variable MAGICK_CONFIGURE_PATH.
Refer to the » ImageMagick configuration files documentation
for further details.

Found A Problem?

gmorris at ilogsystems dot com

15 years ago

I struggled to get imagick installed for mamp and dug high and low. I
was left with the impression that so many struggle with opensource and
this type of install that it is almost a right of passage. For my part, I
managed to find two threads that helped me and the steps work. A lot
of people talked about macports and pear installs which are fine(I tried
them), but 1) they sometimes don't get the latest version of what
you need and 2) I can't tell what they're doing and where they're doing it.

It's much easier to me to download the stuff where i want it and be
sure of what i got!

First of all download a tar image of the ImageMagick install from here:
sourceforge.net/projects/imagemagick/files/

Unpack it and then from terminal issue the following commands in
quotes:
1. "cd ImageMagick-6.5.7" - go where you placed the folder

2. "./configure"

3. "make"

If ImageMagick configured and compiled without complaint, you are
ready to install it on your system. Administrator privileges are
required to install. To install, type the following command in terminal:

1. "sudo make install"

To check your ImageMagick installation enter the following command
in terminal:

1. "make check"

Remember all commands are entered into terminal in the directory in
which you unzipped your downloaded ImageMagick tar file. (the latest
version of which at this time of writing is ImageMagick-6.5.7.)

Next we need to install Imagick.so which is what we want for PHP.

First of all we need to get the right file and we can get that from here:

pecl.php.net/package/imagick/download

At current writing the latest stable version is imagick-2.3.0.

Unpack the tar file and then enter the commands in quotes in terminal:

1. "cd imagick-2.2.3" - go where you placed the folder

2. "phpize"

3. "./configure --with-imagick=/opt/local"

4. "make"

5. "make install"

If you look at the bottom of the output, it will tell you where it has
placed the imagick.so module. For me it was placed in:

/imagick-2.3.0/modules

which is where i had unpacked the downloaded imagick-2.3.0 file.

Then copy it into your MAMP PHP extensions folder.

For me it was:
/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts
-20050922/

Then, for PHP to honor the the extension, add the following line to the
extensions section of your php.ini file:

extension=imagick.so

You should now have a working imagick extension with all of the
resources for php found here:
php.net/manual/en/book.imagick.php

I will not claim credit for anyone for whom this works, that goes to:

Imagemagick who posted instructions here:
www.imagemagick.org/script/install-source.php

and Wallance who posted his experience here:
www.daniweb.com/forums/thread194181.html#

I really hope this helps others because developing this stuff is
frustrating enough without spending hours or even days just trying to set
up the development environment so you can use the tools.

barthuisman at gmail dot com

8 years ago

If you're on a Ubuntu or debian machine, please don't dive into all those pecl stuff, but just use:

sudo apt-get install php7.1-imagick

where php7.1 is your php version, so could be different.

holdoffhunger at gmail dot com

11 years ago

There is a big disclaimer that should be made to all those about to venture on ImageMagick programming using PHP: the great, vast majority of WAMP (Windows-Apache-MySQL-PHP) servers do not support ImageMagick commands at all, since it is a "different package," and there appears to be no way to install ImageMagick through standard Add/Remove Applications within Linux (as far as standard Debian linux releases go). It's very easy to get Apache/PHP running in either Windows or Linux with pretty much any standard OS/distro supported so that you can run all of your own code on your own computer. But that's definitely not the case when you want Imagick to cooperate with your Apache server and your PHP code!


It took me almost an entire week just to get Apache/PHP/ImageMagick working all together nice and happily so that I could run my own PHP code on my own machine (natively, too). So, I decided to simply write down the steps, to help anyone else out who could need help.


Guide to Building an Apache/PHP/Imagick Server with Linux/CentOS 6.4:::


1. Install CentOS 6.4. (Theoretically, other versions of CentOS should work as well, but I simply chose the most recent one.) Also, you can very easily emulate CentOS within Windows (for instance, the unfree choice of VMWare).

2. Install PHP, PHP-Common, PHP-extensions, etc., from standard Application Package Manager ("Add/Remove Programs", usually in system tools somewhere). (You don't have to worry about Apache, because that comes with CentOS 6.4 anyway.)

3. Open up a terminal and enter admin mode with the command "su". You'll need a password for this.

4. Enter this command: yum install ImageMagick ImageMagick-devel

5. Enter this command: pecl install imagick

6. Modify php.ini and include the line "extension=imagick.so". This file is located at "/etc/php.ini" normally. The line must be exactly inserted in the section of "Dynamic Extensions", which begins with this commented out text:


--------------------------------

;;;;;;;;;;;;;;;;;;;;;;

; Dynamic Extensions ;

;;;;;;;;;;;;;;;;;;;;;;

--------------------------------


Use the "search" feature of gedit to find the text. Add the extension below the commented out note in this section so that the result looks like:


--------------------------------

;;;;

; Note: packaged extension modules are now loaded via the .ini files

; found in the directory /etc/php.d; these are loaded by default.

;;;;


extension=imagick.so

--------------------------------


Putting the extension directly at the top caused me serious permission issues in running Imagick code. Also, with CentOS, the permissions automatically disable user control for this php.ini. Enter the following terminal command: "chown [YOUR-USERNAME] -R /etc/php.ini", without the quotes to get control to modify it. Note to insert your username where it states "[YOUR-USERNAME]".

7. Enter this command: "service httpd restart", without quotes, from admin mode. This restarts Apache/PHP/PHP's extensios now that you've installed ImageMagick. If this gives you an error, just try "service httpd start".


My favorite part about this method is that you can update your system with issuing the "yum update" command and then the "yum upgrade" command -- and the Apache/PHP/Imagick combo will still be working perfectly! Unlike some other guides out there for this, you don't need to rely on antiquated, unsupported versions that can be nearly impossible to find. Also, you don't need to worry about the MySQL, Hash, MBString, Exif packages, because they all seem to be installed and properly cooperating with PHP automatically after installing PHP from the Application Manager. This solution makes everything work well together.


The root directory of your public files is located at /var/www/html/. Normally, this folder is not owned by the user, so you'll get a permission error when trying to add files or folders to it. Correct that with entering admin mode in the terminal/command-line window ("su" command) and entering the following command: "chown [YOUR-USERNAME] -R /var/www/html/", without quotes. Again, replace "[YOUR-USERNAME]" with your actual user name. (Warning: The first time I did this, I was lazy and entered the command for only the "/var/" folder, which prevented my system ever from booting. It would always freeze with the notorious and googleable erro-message: "Could not update ICEauthority file /var/lib/gdm/.ICEauthority". So, make sure to change ownership only for "/var/www/html/".)


To view your root directory files as compiled, resultant, PHP pages, open up a browser and enter "127.0.0.1" as the address. So, a file in your root directory would be accessed at the following URL in your browser: http://127.0.0.1/your.file.php . If you get a "could not connect" error message, try the command "service httpd start" at the terminal window from admin mode. (You have to start this service manually every time the machine boots, although there's plenty of ways to automate it.)


I hope this helps! I tried a hundred different guides on getting Apache/PHP/Imagick to work together and none of them worked. Don't give up! ImageMagick is a package of really neat imaging functions!

Robert Badi Baldursson

7 years ago

I have XAMPP version 3.2.2 and PHP 7.1. I was having trouble installing imagick by following Ian Co's notes and then some other very well written tutorials.

However, the imagick module would never show up in phpinfo() but only in the console when typing "php -i" which I found very odd.

It finally turned out that the mistake was to tell me to copy ImageMagic's CORE_RL_* and IM_MOD_RL_* files to C:\xampp\Apache\bin. They needed to be copied to the php root folder where php.exe resides (C:\xampp\php).

When I did that ... boom ... imagick module appeared in phpinfo() finally!

kmteoh at hotmail dot com

10 years ago

Baasha

12 years ago

To install on debian simply try:

apt-get install php5-imagick

on ubuntu:

sudo apt-get install php5-imagick

Anonymous

2 years ago

Using imagick with xampp on windows 10:

it took me some time to make it work but in the end it was just me messing up what version of imagick i downloaded.

go to C:\xampp\htdocs and create a test.php file with:
<?php
phpinfo
();
?>

open C:\xampp\xampp-control.exe and start your Apache server.

in your browser open http://localhost/test.php

`CTRL F` search for `PHP Version` and write down the PHP version. (example: 7.2.24)

`CTRL F` search for `Thread Safety` and check if its enabled of disabled (example: Enabled)

`CTRL F` search for `Architecture` and the Architecture type (example: x64)

go to https://mlocati.github.io/articles/php-windows-imagick.html and select your php version, thread safety and Architecture and download the .zip. (example php_imagick-3.4.4-7.2-ts-vc15-x64.zip)

place the zip inside of C:\xampp\php and extract it.

also place the zip inside of C:\xampp\php\ext and extract it.

open file C:\xampp\php\php.ini and `CTRL F` search for `; Dynamic Extensions ;` and add the line `extension=php_imagick.dll`.

open C:\xampp\xampp-control.exe and restart your Apache server.

in your browser open http://localhost/test.php and `CTRL F` search for `imagick` and it should be added.

Ultimater at gmail dot com

15 years ago

Installing Imagick on Windows isn't too hard. I followed the guide at http://valokuva.org/?page_id=50 and managed to install it without too much sweat.

1. Visit http://imagemagick.org/script/binary-releases.php#windows and download "ImageMagick-6.5.4-6-Q16-windows-dll.exe"

2. Pick a version at http://valokuva.org/outside-blog-content/imagick-windows-builds/ The directories are in YYMMDD format. The latest version that worked for me was 2008-Jul-09 so download 080709/php_imagick_dyn-Q16.dll respectively.

3. Rename php_imagick_dyn-Q16.dll to "php_imagick.dll" and move it to php/ext

4. open php.ini, and make sure
extension=php_imagick.dll
appears in the file and uncommented then resave.
Note: phpinfo() will tell you the location of the loaded php.ini file.

5. Re-start your webserver.

That's it, a simple test will tell you if your installation was successful.
<?php
$im
= new Imagick();
$im->newPseudoImage(100, 100, "magick:rose");
$im->setImageFormat("png");
$im->roundCorners(5,3);
$type=$im->getFormat();
header("Content-type: $type");
echo
$im->getimageblob();
?>

gollariel at gmail dot com

9 years ago

I had an error during installation:

checking ImageMagick MagickWand API configuration program... found in /usr/bin/Wand-config
checking if ImageMagick version is at least 6.2.4... configure: error: no. You need at least Imagemagick version 6.2.4 to use Imagick.
ERROR: `/tmp/pear/temp/imagick/configure --with-imagick' failed

Set is obtained as follows:

sudo apt-get remove graphicsmagick-libmagick-dev-compat imagemagick imagemagick-common
sudo apt-get autoremove
sudo apt-get install libmagickwand-dev
sudo pecl install imagick-beta

scottchu dot tw at gmail dot com

15 years ago

PECL install imagick contantly fails due to the server is behind some firewall, so one may try 'phpize' way to install.

However, someone like me who doesn't want to use default options may experience thru failure situation. And if you google thru the cloud, you may find many people tell you to rpm imagick-devel with yum or apt. That does solve the problem.

However, In my case, my server already has php 5.3.1 installed under /usr/lcal/php & the linux doesn't have yum or apt service. Furthermore, I just installed imagemagick yesterday (Also quite a battle =.=) under /usr/local/imk

(note: You may see that I don't like default options, I like to install each package under different dir under /usr/local).

Today, I want to install imagick, so this is what I do:

1> add /usr/local/php/bin & /usr/local/imk/bin to path.

2> download imagick source of intended version (I use 3.0.b1).

3> enter that dir & issue 'phpize'.

(note:I got a habit to issue './configure --help > oo' & 'view oo' to see all the options first before installation)

4> 'vi configure' & find LIBS, then add '-l/usr/local/imk/lib' after it.

5> issue './configure --prefix=/usr/local/ik4php' --with-imagick='/usr/local/imk'.

(note: with-imagick points out where you install the imagicmagick package before, this name 'imagick' is not appropriate since it incurs ambiguity with imagick for php =.=)

6> after it's done, issue 'make'.

7> after make is done, issue 'make install'.

(note:the last two output lines will tell you where to find the generated shared object library file: imagick.so)

8> go to that dir & copy imagick.so to the extension dir defined in php.ini.

(note: in my case it's /usr/local/php/ext)

9> edit php.ini to add 'extension=imagick.so' line.

10> stop & start apache or just restart apache.

(note: if you have tomcat + apache + jk module installation style as mine, shutdown tomcat, stop apache, then startup tomcat first, then start apache)

If you have similar server environment & situation as mine, hope this article helps you.

Scott Chu @ Taiwan

feedback at weknowtoomuch dot com

11 years ago

I have PHP 5.3.24

I just did that:
- Download proper extension version from
http://windows.php.net/downloads/pecl/releases/imagick/
I picked 3.1.2 which is the latest non-beta at this time
- Unzip and copy php_imagick.dll to PHP ext folder
- add
[PHP_IMAGICK]
extension=php_imagick.dll
to php.ini
- Download recommended Imagick version and install from:
http://imagemagick.org/script/binary-releases.php#windows
( I chose to have C headers and also COM objects during installation)
- Restart apache
- Check phpinfo() for Imagick section... there it is!

Nothing out of ordinary for a PHP extension... I don't know what the fuss is...

support at vipp dot com dot au

9 years ago

I tried installing imagick extension on WHM/Cpanel but it didn't work. the error message was
could not extract the package.xml file
This seems to be a bug in PHP 5.5 as reported by users.

I finally installed this extension from command line. Here are the steps I used just in case someone is experiencing similar problem and is looking for a solution.

1. install ImageMagick from rpm repository in WHM. the version I installed is ImageMagick 6.7.2-7

2. log in the server via ssh,

3. download the latest version of imagick, unpack and install. the version I downloaded is imagick-3.3.0RC2.tgz

wget http://pecl.php.net/get/imagick-3.3.0RC2.tgz
tar xvf imagick-3.3.0RC2.tgz
cd imagick-3.3.0RC2
phpize
./configure
make
make install

the extension was successfully installed

4. in WHM, go to PHP configuration editor, in advanced mode, search extension, and add imagick.so in the list of extension enabled. this can of course be added using a command line editor.

extension=imagick.so

5. restart apache. imagick is there now.
My server runs
PHP Version 5.5
cPanel Version 11.50.0 (build 30)

I hope it works for someone else too.

microzonebitzz at yahoo dot com

8 years ago

With Ubuntu 16.04 (Xenial) with PHP 5.6 not 7. PHP 7 was disabled.

1. sudo apt-get update
2. sudo apt-get install imagemagick php5.6-imagick

vbsaltydog

14 years ago

I could not install via PECL or compiling from source because of an error from line 3339 of the configure file generated by phpize so I looked at the configure file at line 3339 and it was just a check for the PHP version using the php-config command with the --vernum switch which was not supported by my PHP version so I commented out that check from the configure file and then it would configure, compile, and install.

After installation, it put the shared object file in my php extension modules directory so I added an entry to my /etc/php.d directory to load the extension file and restarted apache and the imagick section is present in my info.php output.

Martin Vincent

15 years ago

For PHP 5.3 I have read that these versions should work:
ImageMagick-6.5.9-0-Q16-windows-dll.exe
imagick-2.3.0-dev/vc9_nts/php_imagick.dll

Anonymous

16 years ago

Installation of Imagick on Windows:
-------------------------------------------

Here an important hint for all who want to use Imagick:

First of all: Forget this PECL.
It is for Linux only.

In the old discussion boards I read that some years ago there was a DLL for PHP available on the FTP server of imagemagick.org. Once upon a time there has also been a CHM installation help file on FTP which also has been removed. The only thing you find today on the FTP server is a ridiculous text file:
ftp://ftp.imagemagick.org/pub/ImageMagick/php/windows/README.txt
This file contains 3 links:
2 links of them are dead meanwhile.
The only working one is this:
www.dirk.sh/dirk/magickwand
a page of a chinese guy who offers a MagickWand.dll for PHP of 4 MB size (Q8, static compiled)
But he discontinoued support since 2007.
There is no installation manual available.

He only writes:
"Please ref watson's post about how to install on Windows:
redux.imagemagick.org/discourse-server/viewtopic.php?t=4708"

This page which uses stupid style sheet settings like "font-size:11%" which make parts of the text unreadable also was no help.

At the end all manuals say the same:
Copy the DLL into the "ext" folder and add the entry to the php.ini:
extension=dllname
restart the Apache and you are done.

But this is not true: it simply does NOT work on Xampp.
In a DOS box entering
PHP.exe -i > Info.txt
prints all installed modules.
You also find:

"magickwand
MagickWand Backend Library => ImageMagick
MagickWand Extension Version => 1.0.5
ImageMagick support => enabled
ImageMagick version => ImageMagick 6.3.5 09/21/07 Q8 www.imagemagick.org
ImageMagick QuantumRange (MaxRGB) => 255
MagickWand supported image formats => A, ART, AVI, AVS, B, BIE, BMP, BMP2, BMP3, etc.."

But after executing phpinfo() MagickWand does NOT appear under the installed extensions. Strange!!
And the Wand commands do NOT function like:
$resource = NewMagickWand();

I also found a php_imagick.dll of 65 kB size in the internet which also does not work. It does not even appear in
PHP -i.

There is no error in the Apache logfile!

I read all I could find in the internet and wasted 2 entire days, without success, now I'm sick of Imagick and I absolutely cannot understand why the guys of imagemagick.org don't offer a ready compiled dll with an installation manual anymore?

In general the Imagick page seems not very trustworthy:
On the download page they do never explain what is the difference between the several versions. What doess static mean?
They never explain. (Static means that the convert.exe does not depend on so many dlls. It only requires one external DLL, for that it has a size of 5 MB instead of 200 kb)
And the explanation about the difference between Q8 and Q16 version is wrong: Q8 does NOT mean 8 Bits per pixel as the download page says. It means 8 Bit per color = 24 Bit per Pixel)

And I found an ugly misdesign:
If you install the Q8 version on your local PC and want to copy the files from your harddisk to the server, then convert.exe will crash!
Convert.exe depends on a Registry Entry. And if this is missing (on a server where you have not full access) it will crash. The strangest thing is that this registry key can contain any nonsense, it only must exist! How stupid!

So if you want to execute as an alternative the commandline tools like convert.exe from your PHP code you must add this Registry entries to the server:
HKEY_LOCAL_MACHINE\SOFTWARE\ImageMagick\6.5.1\Q:8\ConfigurePath
The value can be anything.

But with the commandline tools you cannot obtain the width and height of an image in your PHP code. This is not possible.

brunomarcospereira at gmail dot com

7 years ago

How to install Imagick in Windows 10 with PHP Built In Server:

1.0 - Download Imagick with its dependencies on: https://windows.php.net/downloads/pecl/deps/
1.1 - Copy all the .DLL from the "bin" folder to the root of your PHP (e.g.: C:\php-7.1.2-Win32-VC14-x64);
2.0 - Download the DLL according to your version of PHP in: http://pecl.php.net/package/imagick/3.4.3/windows
2.1 - Copy the DLL "php_imagick.dll" to the "ext" directory (e.g.: C:\php-7.1.2-Win32-VC14-x64\ext).
3.0 - Add the line in php.ini: extension=php_imagick.dll
4.0 - Restart the PHP server.

Note: the mime-types of the images will be "image/x-jpeg", "image/x-png"...

Dmitry Semenov

12 years ago

If you tried to install it on Linux and got this message

pecl install imagick

/var/tmp/imagick/php_imagick.h:49:31: fatal error: wand/MagickWand.h: No such file or directory
compilation terminated.
make: *** [imagick_class.lo] Error 1
ERROR: `make' failed

this is what solves it:

yum install ImageMagick-devel

In order to install the imagick PHP extension on Windows, you need to know the exact version of your PHP.
To do this: open a command prompt and enter these commands:

  • Determine the PHP version:
    php -i|find "PHP Version"

  • Determine the thread safety
    php -i|find "Thread Safety"
    You’ll have enabled for thread safe or disabled for not thread safe

  • Determine the architecture
    php -i|find "Architecture"
    You’ll have x86 for 32 bits and x64 for 64 bits

Once you determined the above parameters, you have to download the dll of the PHP extension and the ImageMagick archive using the following table:

Version Thread Safe Architecture Estension
5.5 Yes x86 php_imagick-3.4.3-5.5-ts-vc11-x86.zip
5.5 Yes x64 php_imagick-3.4.3-5.5-ts-vc11-x64.zip
5.5 No x86 php_imagick-3.4.3-5.5-nts-vc11-x86.zip
5.5 No x64 php_imagick-3.4.3-5.5-nts-vc11-x64.zip
5.6 Yes x86 php_imagick-3.4.3-5.6-ts-vc11-x86.zip
5.6 Yes x64 php_imagick-3.4.3-5.6-ts-vc11-x64.zip
5.6 No x86 php_imagick-3.4.3-5.6-nts-vc11-x86.zip
5.6 No x64 php_imagick-3.4.3-5.6-nts-vc11-x64.zip
7.0 Yes x86 php_imagick-3.4.3-7.0-ts-vc14-x86.zip
7.0 Yes x64 php_imagick-3.4.3-7.0-ts-vc14-x64.zip
7.0 No x86 php_imagick-3.4.3-7.0-nts-vc14-x86.zip
7.0 No x64 php_imagick-3.4.3-7.0-nts-vc14-x64.zip
7.1 Yes x86 php_imagick-3.4.4-7.1-ts-vc14-x86.zip
7.1 Yes x64 php_imagick-3.4.4-7.1-ts-vc14-x64.zip
7.1 No x86 php_imagick-3.4.4-7.1-nts-vc14-x86.zip
7.1 No x64 php_imagick-3.4.4-7.1-nts-vc14-x64.zip
7.2 Yes x86 php_imagick-3.4.4-7.2-ts-vc15-x86.zip
7.2 Yes x64 php_imagick-3.4.4-7.2-ts-vc15-x64.zip
7.2 No x86 php_imagick-3.4.4-7.2-nts-vc15-x86.zip
7.2 No x64 php_imagick-3.4.4-7.2-nts-vc15-x64.zip
7.3 Yes x86 php_imagick-3.6.0-7.3-ts-vc15-x86.zip
7.3 Yes x64 php_imagick-3.6.0-7.3-ts-vc15-x64.zip
7.3 No x86 php_imagick-3.6.0-7.3-nts-vc15-x86.zip
7.3 No x64 php_imagick-3.6.0-7.3-nts-vc15-x64.zip
7.4 Yes x86 php_imagick-3.7.0-7.4-ts-vc15-x86.zip
7.4 Yes x64 php_imagick-3.7.0-7.4-ts-vc15-x64.zip
7.4 No x86 php_imagick-3.7.0-7.4-nts-vc15-x86.zip
7.4 No x64 php_imagick-3.7.0-7.4-nts-vc15-x64.zip
8.0 Yes x86 php_imagick-3.7.0-8.0-ts-vs16-x86.zip
8.0 Yes x64 php_imagick-3.7.0-8.0-ts-vs16-x64.zip
8.0 No x86 php_imagick-3.7.0-8.0-nts-vs16-x86.zip
8.0 No x64 php_imagick-3.7.0-8.0-nts-vs16-x64.zip
8.1 Yes x86 php_imagick-3.7.0-8.1-ts-vs16-x86.zip
8.1 Yes x64 php_imagick-3.7.0-8.1-ts-vs16-x64.zip
8.1 No x86 php_imagick-3.7.0-8.1-nts-vs16-x86.zip
8.1 No x64 php_imagick-3.7.0-8.1-nts-vs16-x64.zip
8.2 Yes x86 php_imagick-3.7.0-8.2-ts-vs16-x86.zip
8.2 Yes x64 php_imagick-3.7.0-8.2-ts-vs16-x64.zip
8.2 No x86 php_imagick-3.7.0-8.2-nts-vs16-x86.zip
8.2 No x64 php_imagick-3.7.0-8.2-nts-vs16-x64.zip
8.3 Yes x86 php_imagick-3.7.0-8.3-ts-vs16-x86.zip
8.3 Yes x64 php_imagick-3.7.0-8.3-ts-vs16-x64.zip
8.3 No x86 php_imagick-3.7.0-8.3-nts-vs16-x86.zip
8.3 No x64 php_imagick-3.7.0-8.3-nts-vs16-x64.zip
8.4 Yes x86 php_imagick-3.7.0-8.4-ts-vs17-x86.zip
8.4 Yes x64 php_imagick-3.7.0-8.4-ts-vs17-x64.zip
8.4 No x86 php_imagick-3.7.0-8.4-nts-vs17-x86.zip
8.4 No x64 php_imagick-3.7.0-8.4-nts-vs17-x64.zip

Once you downloaded the correct files:

  1. Extract from php_imagick-….zip the php_imagick.dll file, and save it to the ext directory of your PHP installation
  2. 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
  3. Add this line to your php.ini file:
    extension=php_imagick.dll
  4. Restart the Apache/NGINX Windows service (if applicable)

To test if the extension works, you can run this PHP code:

<?php
$image = new Imagick();
$image->newImage(1, 1, new ImagickPixel('#ffffff'));
$image->setImageFormat('png');
$pngData = $image->getImagesBlob();
echo strpos($pngData, "\x89PNG\r\n\x1a\n") === 0 ? 'Ok' : 'Failed'; 

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

Cover image for How to install Imagick PHP extension in Windows (Updated)

In this article, I will show you step-by-step how to install ImageMagick PHP extension in Windows. Make sure you follow the steps carefully so that you can successfully install it.

About ImageMagick

Based on imagemagick.org, ImageMagick is a free, open-source software suite, used for editing and manipulating digital images. It can be used to create, edit, compose, or convert bitmap images, and supports a wide range of file formats, including JPEG, PNG, GIF, TIFF, and PDF.

How to install

Step 1
Before you install Imagick, you must first check the PHP version, PHP architecture, and whether your PHP is Thread Safety or not.

You can check this by creating a PHP program that runs the phpinfo() function.

See the image below:

PHP Version

You can see that the PHP version I’m using is version 8.1.10, the architecture is x64, and the thread safety is enabled.

Step 2
After that, you have to download the Imagick package, you can download it from this link Imagick For Windows, select the DLL option for Windows.

PHP PECL

Choose a version that is stable and matches your PHP version. In this case, my PHP version is 8.1+.

Step 3
Extract and copy the file with the name php_imagick.dll that is in the php_imagick folder that you have downloaded in the second step.

PHP Imagick Folder

Step 4
Paste the php_imagick.dll file in the ext folder where your PHP folder is located.

PHP Folder Ext

In this case, I’m using Laragon.

Step 5
Copy all the files with .dll format (except php_imagick.dll) in the php_imagick folder that you have downloaded in the second step.

PHP Imagick Folder

Step 6
Paste all the .dll files you copied into your PHP folder.

PHP Folder

Step 7
Change the contents of the file named php.ini in the PHP folder by adding extension=imagick and save it.

php.ini

In some cases, you have to type it like this extension=php_imagick.dll, it depends if the other listed extensions include the .dll format or not.

Step 8
Restart your apache and check whether the imagick extension is installed or not using the phpinfo() function.

If successfully installed then you will find an extension with the name imagick when you run the phpinfo() function.

See the image below:

php info()

Notes: If you use Laragon, you must check the imagick extension first. The method is by right-clicking on Laragon, select PHP then go to the extensions menu and search for imagick.

Closing

These are the step-by-step how to install ImageMagick PHP extension in Windows. Hopefully the article is useful for you and don’t forget to leave a comment on the article.

Так как не найдя в интернете вразумительного мануала как установить данное дополнения решил написать этот пост. Все нижеописанное делалось под windows 7 ultimate x64.

1. Скачиваем ImageMagick

Собственно идем по ссылке imagemagick.org/script/binary-releases.php#windows и скачиваем последнюю версию ImageMagick-6.8.3-4-Q16-x86-dll.exe

2. Установка ImageMagick.

В принципе установить можно в любую директорию, даже в папку с PHP.

Внимание. Следите за тем, чтобы стояла галочка «Add to system path» так как обращение будет происходить через переменную окружения Path. После установки желательно перезагрузить PC, чтоб пути Path вошли в действие.

3. Загрузка расширения php_Imagick.dll

Для разных версий PHP нужны разные dll
Для

PHP 5.2.x

файлы лежат здесь valokuva.org/outside-blog-content/imagick-windows-builds/080709
Расшифровка: dyn = dynamic, st = static, q16 = 16 bit, q8= 8 bit. В зависимости от той сборки dll которую вы скачали и установили вам нужно скачать соответствующую библиотеку
Для

PHP 5.3.x

есть разделение на 2 ветки
Если у вас PHP VC

6

в зависимости от Thread Safety вам нужна одна из этих dll www.sk89q.com/downloads/imagick/2.3.0
Если у вас PHP VC

9

в зависимости от Thread Safety вам нужна одна из этих dll valokuva.org/outside-blog-content/imagick-windows-builds/php53/imagick-2.3.0-dev

4. Настройка PHP

Копируем наш загруженный php_imagick.dll в папку с PHP(/php/ext/), и редактируем php.ini. В главный раздел в конец дописываем строчку

extension=php_imagick.dll

и перезагружаем веб сервер.

Собственно все. Все должно работать.
PS. Для тех у кого все нае заработало с первого разу и при попытке выполнить код типа

<?php 
header('Content-type: image/jpeg');

$image = new Imagick('apache_logo.png');

// Если в качестве ширины или высоты передан 0,
// то сохраняется соотношение сторон
$image->thumbnailImage(100, 0);

echo $image;


?>

apache вылетает с ошибкой и ругается на файл MSVCR100.dll есть решение. Проблема в том, что это файл Visual C++ Redist 2010 и Microsoft что то накосячили в новой версии потому выход один. Скачать болие старую версию imagick. К примеру ImageMagick 6.5.0 вот отсюда mhonarc.veidrodis.com/image_magick/binaries
PSS. Можно отвязать ImageMagick от его текущего местоположения, взявь и скопировав все dll из папки ImageMagick в /apache/bin/

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Как переустановить калькулятор windows 10
  • Как поставить все драйвера на windows 11
  • К какому железу привязывается лицензия windows
  • Переименовать учетную запись windows 10 реестр
  • Taskeng exe что это за процесс windows 7 как исправить