note 44585 added to function.imagetypes
| From: | csst0266 at cs dot uoi dot gr | Date: | Tue, 10 Aug 2004 07:05:28 +0000 |
| Subject: | note 44585 added to function.imagetypes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-74394@lists.php.net to get a copy of this message | ||
Here is my function that returns a comma-separated string of the image types supported by GD. It
uses the gd_info() function (which tells us if GIF reading is supported, so even this should not be
a problem anymore):
<?php
function getImageTypes() {
$gdinfo = gd_info();
if ($gdinfo['GIF Read Support']) {
$types[] = 'GIF';
}
if ($gdinfo['JPG Support']) {
$types[] = 'JPG';
}
if ($gdinfo['PNG Support']) {
$types[] = 'PNG';
}
if ($gdinfo['WBMP Support']) {
$types[] = 'WBMP';
}
if ($gdinfo['XBM Support']) {
$types[] = 'XBM';
}
return implode(', ', $types);
}
?>
In the above version of the function, the presence of GIF in the result means read support. It does
not guarantee create support. If you want GIF to guarantee read and create support, then you may
find this version of the function useful instead:
<?php
function getImageTypes() {
$gdinfo = gd_info();
if ($gdinfo['GIF Create Support']) {
$types[] = 'GIF';
}
if ($gdinfo['JPG Support']) {
$types[] = 'JPG';
}
if ($gdinfo['PNG Support']) {
$types[] = 'PNG';
}
if ($gdinfo['WBMP Support']) {
$types[] = 'WBMP';
}
if ($gdinfo['XBM Support']) {
$types[] = 'XBM';
}
return implode(', ', $types);
}
?>
Hope this helps. :)
----
Manual Page -- http://www.php.net/manual/en/function.imagetypes.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44585
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44585&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44585&report=yes
Search -- http://master.php.net/manage/user-notes.php