Jul/0918
Installing ImageMagick on Windows and Using with PHP – Imagick
As most of your know ImageMagick is like the photoshop on your console demand. Best with their explanation.
ImageMagick® is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.
It is very powerful and supports all platforms with tons of different languages and implementations. Because my hosting solutions did not suppot it (many of them dont do as well) I always used awesome GD library to process images on my projects. Well now my hosting does support and I am going to use it so I needed to install it to my development environment which is windows. I am going to install and use Imagick also because using IM from native PHP is much more faster than using it from console via exec.
Well first of all ImageMagick on windows with PHP is a really pain in the ass, if you have the commitment and time go for it otherwise use it from console. Here are the steps and todo's to install for PHP 5.2.x, ( I dont know if it works with PHP 5.3.x or below, you will need to test for yourself. I am a happy camper for now ).
1 Download ImageMagick
Go to http://imagemagick.org/script/binary-releases.php#windows to download the latest version, which is ImageMagick-6.5.4-2-Q16-windows-dll.exe
Now the beauty, static versions are suppose to work with every platform but they act really funny so you should download a dynamic version. If you system/pc supports go for 16 bit Q16. The difference is explained on the link very well.
Now in my case, the latest version did not work so I had to go through old versions and ImageMagick-6.4.2-7-Q16-windows-dll version worked like charm for me. My system is Windows XP SP2, 32 Bit, Intel Centrino 1.76GHZ. You can download the older versions from here.
I suggest you to download and try the latest one, complete all steps, if it doesnt work try with a lower version and so on.
2 Install ImageMagick
Install the IM on a path like C:\imagemagick\ with no spaces and simple location. Do not go for c:\program files\etc
Do not forget to click on the "Add to system path" checkbox. You can ignore the rest of the checkboxes
3 Testing the Installation
Open the command prompt (Run->"CMD"->ENTER) and type in convert and press enter. You should see the help parameters of convert. If so go to step 4.
if it says its failed or unknown function or type in a parameter to convert ( which is a default function in Windows XP to convert HDD from FAT32 to NTFS or vice varsa ) you need to add path to environment by yourself.
My Computer -> Right Click -> Properties -> Advanced (Tab) -> Environment Variables (at the bottom) -> System Variables (Section) -> Scroll to Find "Path" -> Select it and click Edit -> Add your installation directory to there.
4 Downloading the php_Imagick.dll
Again the version problem, well if you are using PHP 5.2.x this is where you will get your dll.
dyn = dynamic, st = static, q16 = 16 bit, q8= 8 bit. This should match your downloaded version of course. If you downloaded q16 dynamic library, your file will be php_imagick_dyn-Q16.dll
If you are using PHP 5.3.x, this is your location to download.
5 Find and Place the dll in your extension folder
Rename the downloaded dll to php_imagick.dll for easy usage and place it under your extension folder. It is usually php/ext/. Go to Step 6.
If it is not, then you can find it in your php.ini file with the extension_dir param.
; Directory in which the loadable extensions (modules) reside.
extension_dir = "Something something"
6 Edit PHP.ini
Uncomment if it exists or add if it doesnt exist this line
extension=php_imagick.dll
7 Restart
This is the important part, I spent good half an hour trying to make it work.. grrrr.. You need to restart your PC to libraries take effect.
If you do not restart and start your apache you will see an error like. So please do restart your PC.
Unable to find CORE_RL_Wand.dll something something.
8 Start Apache and check
Start your apache, and check with the phpinfo() , if you see imagick library and its values thats it you are set. go to step 9.
If not you have picked up the wrong dll file for PHP. Browse through the directory and try another dlls, if they dont work try to lower your ImageMagick installation version. Dont give up, it will work.
9 Test with some code
Put a nice big picture named a.jpg along side with your test.php script, run the test and check the directory to see a_thumnail.jpg. Here is the script, simple and fast
<? $im = new imagick( 'a.jpg' ); // resize by 200 width and keep the ratio $im->thumbnailImage( 200, 0); // write to disk $im->writeImage( 'a_thumbnail.jpg' ); ?>
10 Manual, Learning and Playing Around
To use it from php all you need is PHP functions and manual including some examples as well.
If you want to go further and mess around here is the command line ( exec() ) parameters, manuals and examples
Finally
So this is it, I hope you get it to work at the first trial now and drop a comment if you have any useful information or experience any error, we will try to help you out.
No related posts.















July 17th, 2009
Hi
THank you very much for this tutorial.
I have following all the steps and restarted the machine.. everything working fine excepts the last one (9).
am getting the following error
Fatal error: Class ‘imagick’ not found
please help
thanks in advance
July 17th, 2009
@Unnikrishnan
do your phpinfo() display the imagick class as described in step 8?
if not then check your php.ini for your dll directory and make sure you are using the correct dll file for your php version.
if yes use uppercase I in the definition.
new ImagickJuly 19th, 2009
Is there a version for PHP 5.3 that is compiled with VC6 which I believe is required for Apache..???
Thanks in advance
July 21st, 2009
@RandyJohnson
Yes I also gave the php 5.3 required dll link.
I believe all the libraries are complied with VC (which version does not matter) if you are having runtime problems make sure you have the .net framework installed (at least 2.0)
Addition to that you can download the source files from
http://pecl.php.net/package/imagick/
and compile one for yourself.
July 29th, 2009
You definetevly need a VC6-compiled version of php_imagick.dll for
apache-binaries. VC9’s are for IIS-environments.
The choice of “thread-safe” vs. “non-thread-safe” is not important on
windows-systems, as its a multi-thread-system, and could handle “nts”.
But VC6-compiled versions of php_xxx.dll’s are a MUST, or your apache won’t start.
July 29th, 2009
Thanks for the clarification
August 20th, 2009
Anyone have any idea where to get the VC6 php_imagick.dll for PHP 5.3.0? All I see in the above supplied site is for VC9, which obviously causes my Apache-based install to shout at me saying wrong VC build.
August 29th, 2009
+1 on the request for a VC6 build. Could someone please upload one? Thanks.
September 19th, 2009
I will upload my version for PHP 5.2.0, hope its ok for you guys.
November 25th, 2009
Thanks man. This was really helpful!
December 13th, 2009
Thanks for the tip of restarting.. save me a lot of time
December 13th, 2009
yw i wished someone told me as well before trying it
January 15th, 2010
Thanks for the howto. Work perfectly.
PHP Version 5.2.6
ImageMagick-6.5.9-0-Q16-windows-dll
php_imagick_dyn-Q16.dll
January 17th, 2010
Thanks a lot for this. It surely saved me a lot of time/trouble.
It works perfectly for me with the following software:
Windows 7
ISS 7.5
PHP 5.3.1
ImageMagick-6.5.9-0-Q16-windows-dll.exe
imagick-2.3.0-dev/vc9_nts/php_imagick.dll
January 23rd, 2010
Can’t install on a server with plesk php 5.2.6
January 23rd, 2010
I am guessing your Plesk running server is Linux or Unix based but the post is about windows OS. I am guessing plesk have installers like cpanel as well to install imagick kindof stuff.
February 15th, 2010
thanks man, restarting the computer fixed my prob.
March 4th, 2010
i m getting problem at installation time.. windows prompting error
unable to execute file: ppm
shellExecuteEx : failed code 2
can u help me out