note 44585 deleted from function.imagetypes by tomsommer

From: Date: Tue, 10 Aug 2004 13:30:15 +0000
Subject: note 44585 deleted from function.imagetypes by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-74405@lists.php.net to get a copy of this message
Note Submitter: csst0266@cs.uoi.gr ---- 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. :)

« previous php.notes (#74405) next »