xoops forums


Just can't stay away
Posted on: 2009/12/29 13:50
frankblack (Show more)
Just can't stay away
Posts: 830
Since: 2005/6/13

Manual: Using imagemagick with XAMPP on Windows

What a joyride! This wasn't sooo easy, so this manual might be helpful?

The standard installation of XAMPP for Windows makes it nearly impossible to use ImageMagick out-of-the-box, because PHP is compiled with VC6, but we need it to be compiled with VC9 (whatever this means).

What we need is:
PHP 5.3.1 (if you use XAMPP 1.7.3) as VC9 x86 Thread Safe - Take the zip from HERE
ImageMagick from HERE - take the latest version. When experiencing problems you have to install Visual C++ 2008 Redistributable Package (see bottom of this page)
The php_imagick_ts.dll - get it HERE

Installation of all the files (assuming your path to XAMPP is c:/xampp
1. Rename c:/xampp/php to c:/xampp/phpvc6 for good measure, because you need some values from php.ini located in there.
2. Make a new folder called php in c:/xampp. Extract the php.zip and copy the contents of this folder to c:/xampp/php
3. Compare the old php.ini and the new php.ini and make some changes to the new one. Especially watch out for the path to the extension. At the extensions part you have to add one entry: extension=php_imagick_ts.dll
4. Edit c:/xampp/apache/conf/httpd.conf and add the following line at the end of this file:
SetEnv MAGICK_HOME C:/xampp/imagemagick

5. Install imagemagick to c:/xampp. Make sure, that adding the path to imagemagick is checked. Other things do not have to be checked.
6. Restart your PC
7. Start XAMPP and have a look at your phpinfo now.

Test imagemagick with the following code (borrowed from somewhere in the web, sorry can't remember where) and save it to htdocs:

$im = new Imagick();

$draw = new ImagickDraw();

$itWorks "It works!";
$draw = new ImagickDraw();
$metrics $im->queryFontMetrics($draw$itWorks);
$adjustY = ($metrics["textHeight"] + $metrics["descender"]) / 2// ~ vertical align: middle
$draw->annotation(5050 $adjustY"It works!");

header("Content-Type: image/" $im->getImageFormat());

Now browse this file and hopefully everything works - good luck!

edit: you cannot copy all settings from your old php.ini to the new one, because you need dlls for the VC9 version