1
frankblack
Manual: Using imagemagick with XAMPP on Windows
  • 2009/12/29 13:50

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


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:
error_reporting(E_ALL);
ini_set("display_errors"1);

$im = new Imagick();
$im->newImage(100100"green""png");

$draw = new ImagickDraw();
$draw->setFillColor("white");
$draw->setStrokeWidth(1);
$draw->setStrokeColor("black");
$draw->circle(50505090);
$im->drawImage($draw);

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

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


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

Login

Who's Online

321 user(s) are online (196 user(s) are browsing Support Forums)


Members: 0


Guests: 321


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits