note 23150 deleted from ref.image by victor
| From: | victor@php.net | Date: | Mon, 09 Dec 2002 18:38:11 +0000 |
| Subject: | note 23150 deleted from ref.image by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40594@lists.php.net to get a copy of this message | ||
ob_start();
phpinfo();
$phpinfo = ob_get_contents();
ob_end_clean();
$phpinfo = explode("\n",$phpinfo);
$gdversion = 0;
foreach ($phpinfo as $text) {
$parts = explode('</b>',$text);
foreach ($parts as $key=>$val) {
$parts[$key] = strip_tags($val);
}
if ($parts[0]=="GD Version") {
$gdversion = intval($parts[1]);
}
}
switch ($gdversion) {
case 1: echo "version 1.x found"; break;
case 2: echo "version 2.x found"; break;
default: echo "gd not detected, parser error possible, check phpinfo()"; break;
}
might help some of you who want to build true portable code for image manipulation/generation, and
need to know aproximately what functions gd supports and more exactly what gd is installed in php
(if any)
the check should be fine if phpinfo() formatting stayed consistant trough 4.x (i tested this on
4.2.1 and 4.2.0)
in 4.3 you will be able to check gd2 propperly with function_exists("imagecopyresized")
for example.
hope i helped some of you :)