Hallo,
neben der bekannten GD-Library gibt es mit Image Magick noch eine weitere Grafikbibliothek, die es nicht nur als Konsolen-Variante, sondern auch als PHP-Extension gibt:
PHP: ImageMagick - Manual
Unter Windows ist die Installation etwas kompliziert, denn Apache und PHP müssen mit VC9 kompiliert worden sein.
(Das Testsystem ist Windows 7, 64 Bit, allerdings werden zum Testen die x86-Versionen verwenden).
Zunächst muss eine ganze Reihe an Software installiert werden, los geht's:
Image Magick:
ImageMagick: Install from Binary Distribution
Name: Win32 dynamic at 16 bits-per-pixel
Datei: ImageMagick-6.5.8-4-Q16-windows-dll.exe [~12.5 MB]
Nach der Installation Windows durchstarten.
Microsoft Redistributable Package:
Download details: Visual C++ 2008 Redistributable Package (x86)
(sollte sich die URL ändern, einfach googlen)
Name: Microsoft Visual C++ 2008 Redistributable Package (x86)
Datei: vcredist_x86.exe [~ 1.7 MB]
Brav die folgenden Windows-Updates ziehen (nicht zwingend)
XAMPP können wir nicht verwenden, das wird soweit es zu erfahren war mit VC6 kompiliert (also inkompatibel zu Mikko Koppanen's Imagick-Extension für Win/PHP, die VC9 benötigt), wir müssen also auf die von der Apache Lounge bereitgestellte Apache Version zurückgreifen:
Apache:
Apache on Windows binaries and modules download
Name: Apache 2.2.14 apr-1.3.9 apr-util-1.3.9 apr-iconv-1.2.1 openssl-0.9.8k+asm zlib-1.2.3+asm
Datei: httpd-2.2.14-win32-x86-ssl.zip [~ 4.9 MB]
Apache ins empfohlene Verzeichnis C:/Apache2 entpacken. Für den Anfang besser so machen, wäre ärgerlich wenn eine übersehene Konfig-Einstellung das ganze Projekt zum Scheitern bringt. Nach dem alles läuft, kann man immer noch die Komponenten dorthin verlegen, wo man sie haben möchte.
PHP:
PHP For Windows: Binaries and sources Snapshots
Zur Info:
Name: PHP 5.3 (5.3.2-dev) / VC9 x86 Thread Safe
Datei: php-5.3-win32-VC9-x86-latest.msi [~ 19.37MB]
So jetzt PHP installieren, Modul Apache 2.2 wählen, der Speicherort der jetzt abgefragten Apache-Konf ist C:/Apache2/conf
Diese Änderung sollte nach der Installation in der C:/Apache2/conf/httpd.conf zu finden sein:
Imagick-Extension:
x86 Windows builds
Name: imagick - vc9 - ts; 2009-11-18 23:39 - php_imagick_ts.dll (3.0.0-dev)
Datei: php_imagick_ts.dll [~ 261 KB]
Die kommt in unser PHP-Extension-Verzeichnis:
C:\Program Files (x86)\PHP\ext
also
C:\Program Files (x86)\PHP\ext\php_imagick_ts.dll
In der php.ini fehlt jetzt noch der folgende Eintrag:
(ganz ans Ende zum Beispiel)
So, jetzt müssen wir den Apache nochmal als Service installieren, also in die Windows/DOS-Konsole:
So und jetzt können wir gleich testen:
http://localhost/test.php
aka
C:/Apache2/htdocs/test.php:
und jetzt sollte dort das erste Gemälde erscheinen, weißer Kreis mit schwarzem Rand auf grüner Leinwand ... "It works!"
neben der bekannten GD-Library gibt es mit Image Magick noch eine weitere Grafikbibliothek, die es nicht nur als Konsolen-Variante, sondern auch als PHP-Extension gibt:
PHP: ImageMagick - Manual
Unter Windows ist die Installation etwas kompliziert, denn Apache und PHP müssen mit VC9 kompiliert worden sein.
(Das Testsystem ist Windows 7, 64 Bit, allerdings werden zum Testen die x86-Versionen verwenden).
Zunächst muss eine ganze Reihe an Software installiert werden, los geht's:
Image Magick:
ImageMagick: Install from Binary Distribution
Name: Win32 dynamic at 16 bits-per-pixel
Datei: ImageMagick-6.5.8-4-Q16-windows-dll.exe [~12.5 MB]
Nach der Installation Windows durchstarten.
Microsoft Redistributable Package:
Download details: Visual C++ 2008 Redistributable Package (x86)
(sollte sich die URL ändern, einfach googlen)
Name: Microsoft Visual C++ 2008 Redistributable Package (x86)
Datei: vcredist_x86.exe [~ 1.7 MB]
Brav die folgenden Windows-Updates ziehen (nicht zwingend)
XAMPP können wir nicht verwenden, das wird soweit es zu erfahren war mit VC6 kompiliert (also inkompatibel zu Mikko Koppanen's Imagick-Extension für Win/PHP, die VC9 benötigt), wir müssen also auf die von der Apache Lounge bereitgestellte Apache Version zurückgreifen:
Apache:
Apache on Windows binaries and modules download
Name: Apache 2.2.14 apr-1.3.9 apr-util-1.3.9 apr-iconv-1.2.1 openssl-0.9.8k+asm zlib-1.2.3+asm
Datei: httpd-2.2.14-win32-x86-ssl.zip [~ 4.9 MB]
Apache ins empfohlene Verzeichnis C:/Apache2 entpacken. Für den Anfang besser so machen, wäre ärgerlich wenn eine übersehene Konfig-Einstellung das ganze Projekt zum Scheitern bringt. Nach dem alles läuft, kann man immer noch die Komponenten dorthin verlegen, wo man sie haben möchte.
PHP:
PHP For Windows: Binaries and sources Snapshots
Zur Info:
Which version do I choose?
If you are using PHP with Apache 1 or Apache2 from apache.org you need to use the VC6 versions of PHP
If you are using PHP with IIS you should use the VC9 versions of PHP
VC6 Versions are compiled with the legacy Visual Studio 6 compiler
VC9 Versions are compiled with the Visual Studio 2008 compiler and have improvements in performance and stability. The VC9 versions require you to have the Microsoft 2008 C++ Runtime (x86) or the Microsoft 2008 C++ Runtime (x64) installed
Do NOT use VC9 version with apache.org binaries
These binaries are NOT intended for production use; please use the binaries at PHP Windows downloads.
If you are using PHP with Apache 1 or Apache2 from apache.org you need to use the VC6 versions of PHP
If you are using PHP with IIS you should use the VC9 versions of PHP
VC6 Versions are compiled with the legacy Visual Studio 6 compiler
VC9 Versions are compiled with the Visual Studio 2008 compiler and have improvements in performance and stability. The VC9 versions require you to have the Microsoft 2008 C++ Runtime (x86) or the Microsoft 2008 C++ Runtime (x64) installed
Do NOT use VC9 version with apache.org binaries
These binaries are NOT intended for production use; please use the binaries at PHP Windows downloads.
Datei: php-5.3-win32-VC9-x86-latest.msi [~ 19.37MB]
So jetzt PHP installieren, Modul Apache 2.2 wählen, der Speicherort der jetzt abgefragten Apache-Konf ist C:/Apache2/conf
Diese Änderung sollte nach der Installation in der C:/Apache2/conf/httpd.conf zu finden sein:
Code:
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL PHPIniDir "C:/Program Files (x86)/PHP/" LoadModule php5_module "C:/Program Files (x86)/PHP/php5apache2_2.dll" #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
Imagick-Extension:
x86 Windows builds
Name: imagick - vc9 - ts; 2009-11-18 23:39 - php_imagick_ts.dll (3.0.0-dev)
Datei: php_imagick_ts.dll [~ 261 KB]
Die kommt in unser PHP-Extension-Verzeichnis:
C:\Program Files (x86)\PHP\ext
also
C:\Program Files (x86)\PHP\ext\php_imagick_ts.dll
In der php.ini fehlt jetzt noch der folgende Eintrag:
Code:
[PHP_IMAGICK] extension=php_imagick_ts.dll
So, jetzt müssen wir den Apache nochmal als Service installieren, also in die Windows/DOS-Konsole:
Code:
cd C:/Apache2/bin httpd.exe -k install httpd.exe -k restart
http://localhost/test.php
aka
C:/Apache2/htdocs/test.php:
PHP-Code:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$im = new Imagick();
$im->newImage(100, 100, "green", "png");
$draw = new ImagickDraw();
$draw->setFillColor("white");
$draw->setStrokeWidth(1);
$draw->setStrokeColor("black");
$draw->circle(50, 50, 50, 90);
$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(50, 50 + $adjustY, "It works!");
$im->drawImage($draw);
header("Content-Type: image/" . $im->getImageFormat());
echo $im->getImageBlob();
?>
Kommentar