note 15920 added to function.imagetypes
| From: | sjon at php2 dot chek dot com | Date: | Mon, 08 Oct 2001 20:45:34 +0000 |
| Subject: | note 15920 added to function.imagetypes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-18700@lists.php.net to get a copy of this message | ||
Nope, it's a feature... :)
The function returns a bitmask, wich is the product of the IMG_* stuff...
When I run this function, I get 14, wich is IMG_JPG + IMG_PNG + IMG_WBMP (2+4+8), wich is correct,
since I don't have gif support (with gif, I'd get 15).
Here are 2 simple functions to get the available types, or to check if a type is supported:
function _get_image_types () {
$i = ImageTypes();
$r['WBMP'] = ($i >= 8) ? TRUE:FALSE;
$i -= 8;
$r['PNG'] = ($i >= 4) ? TRUE:FALSE;
$i -= 4;
$r['JPG'] = ($i >= 2) ? TRUE:FALSE;
$i -= 2;
$r['GIF'] = ($i >= 1) ? TRUE:FALSE;
return $r;
}
function is_imgtype ($t = "PNG) {
$i = _get_image_types();
return $i[$t];
}
Sjon.
PS: This could be done more efficiently, I think...
--
http://www.php.net/manual/en/function.imagetypes.php
http://master.php.net/manage/user-notes.php?action=edit+15920
http://master.php.net/manage/user-notes.php?action=delete+15920
http://master.php.net/manage/user-notes.php?action=reject+15920