I had a tough time yesterday trying to install ImageMagick on Windows. I got the correct binary file, but when I tried to invoke it with the PHP extension (php_imagick.dll) it was not getting loaded at all!!. Searching all over the web did not help..Finally I managed to fix the problem and felt I should give a clear procedure that will help anybody to install ImageMagick on Windows XP with proper DLL file for PHP. Here is what I did and if you do the same, you should get this working without any problems..
ImageMagick References
Step 1 : Do not download the latest version of ImageMagick. Rather download this version : ImageMagick-6.4.1-0-Q8-windows-dll. You can get this version from the following
link . You get all the versions here. Make sure you pick the right one. If you miss here, you are gone!
Step 2: After downloading it, install the binary. Do not install it to c:\program files..etc..rather install it to a location like c:\imagemagick. (assuming c: as your root directory).
Step 3: After installation, run the 'convert' command from DOS mode. It should work. If it does not, check the PATH environment variable and make sure that 'c:\imagemagick' is added correctly there.
Step 4: We need to add one more environment variable MAGICK_HOME. (New one). The value of this variable should hold the directory path where imagemagick is installed. (c:\imagemagick in this case)
Step 5: I need to set this up on Apache 2.2x with PHP 5.2.6. In the Apache httpd.conf file, add this line to the end of the file. "SetEnv MAGICK_HOME “C:/imagemagick” (without quotes and watch the '/'..Make sure that you refer to the correct path here).
Step 6: Download the
correct extension file for PHP. If you are using the same version that I have listed, then you can get the extension from
here. If this link is broken, let me know.
Step 7: PHP.ini file needs to be updated. Identify the extension directory for PHP correctly and place the DLL file inside the directory. Update the PHP.ini file with this extension.
Step 8: Restart Apache once all this is done.
Step 9: After restart, make sure that the imagick extension got loaded correctly with phpinfo(). If you have done all the above steps correctly, and the extension dll has not got loaded, then you have picked up an invalid dll file. Check the file.
Step 10: Execute a sample code like this (add php header tag)
thumbnailImage(100, 0);
echo $image;
?>
It should work and you are done!!
If you get an error like this
PHP Fatal error: Class 'Imagick' not found in....
Then, the extension file is not loaded properly. Check the extension file.
Any queries, comment in the blog. I shall help to resolve it.. Also, check out the following books..They are highly useful