note 23150 added to ref.image
| From: | tit dot petric at nospam dot telemach dot net | Date: | Wed, 10 Jul 2002 19:33:39 +0000 |
| Subject: | note 23150 added to ref.image | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32853@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 :)
--
http://www.php.net/manual/en/ref.image.php
http://master.php.net/manage/user-notes.php?action=edit+23150
http://master.php.net/manage/user-notes.php?action=delete+23150
http://master.php.net/manage/user-notes.php?action=reject+23150