Skip to content

Instantly share code, notes, and snippets.

@antom
Created April 23, 2015 09:57
Show Gist options
  • Save antom/635ce517f3e66be2c69f to your computer and use it in GitHub Desktop.
Save antom/635ce517f3e66be2c69f to your computer and use it in GitHub Desktop.
Quick checking script to see if PHP's GD extension is enabled & what functions are available.
<?php
$gd_functions = array(
'gd_info',
'getimagesize',
'getimagesizefromstring',
'image_type_to_extension',
'image_type_to_mime_type',
'image2wbmp',
'imageaffine',
'imageaffinematrixconcat',
'imageaffinematrixget',
'imagealphablending',
'imageantialias',
'imagearc',
'imagechar',
'imagecharup',
'imagecolorallocate',
'imagecolorallocatealpha',
'imagecolorat',
'imagecolorclosest',
'imagecolorclosestalpha',
'imagecolorclosesthwb',
'imagecolordeallocate',
'imagecolorexact',
'imagecolorexactalpha',
'imagecolormatch',
'imagecolorresolve',
'imagecolorresolvealpha',
'imagecolorset',
'imagecolorsforindex',
'imagecolorstotal',
'imagecolortransparent',
'imageconvolution',
'imagecopy',
'imagecopymerge',
'imagecopymergegray',
'imagecopyresampled',
'imagecopyresized',
'imagecreate',
'imagecreatefromgd2',
'imagecreatefromgd2part',
'imagecreatefromgd',
'imagecreatefromgif',
'imagecreatefromjpeg',
'imagecreatefrompng',
'imagecreatefromstring',
'imagecreatefromwbmp',
'imagecreatefromwebp',
'imagecreatefromxbm',
'imagecreatefromxpm',
'imagecreatetruecolor',
'imagecrop',
'imagecropauto',
'imagedashedline',
'imagedestroy',
'imageellipse',
'imagefill',
'imagefilledarc',
'imagefilledellipse',
'imagefilledpolygon',
'imagefilledrectangle',
'imagefilltoborder',
'imagefilter',
'imageflip',
'imagefontheight',
'imagefontwidth',
'imageftbbox',
'imagefttext',
'imagegammacorrect',
'imagegd2',
'imagegd',
'imagegif',
'imagegrabscreen',
'imagegrabwindow',
'imageinterlace',
'imageistruecolor',
'imagejpeg',
'imagelayereffect',
'imageline',
'imageloadfont',
'imagepalettecopy',
'imagepalettetotruecolor',
'imagepng',
'imagepolygon',
'imagepsbbox',
'imagepsencodefont',
'imagepsextendfont',
'imagepsfreefont',
'imagepsloadfont',
'imagepsslantfont',
'imagepstext',
'imagerectangle',
'imagerotate',
'imagesavealpha',
'imagescale',
'imagesetbrush',
'imagesetinterpolation',
'imagesetpixel',
'imagesetstyle',
'imagesetthickness',
'imagesettile',
'imagestring',
'imagestringup',
'imagesx',
'imagesy',
'imagetruecolortopalette',
'imagettfbbox',
'imagettftext',
'imagetypes',
'imagewbmp',
'imagewebp',
'imagexbm',
'iptcembed',
'iptcparse',
'jpeg2wbmp',
'png2wbmp',
);
$checks = array(
'GD Extension' => extension_loaded('gd'),
);
foreach($gd_functions as $function) {
$checks[$function . '()'] = function_exists($function);
}
$checks = array_map(
function($value) {
$value = ($value) ? 'yes' : 'no';
return '<span class="' . $value . '">' . ucfirst($value) . '</span>';
},
$checks
);
$table = array();
foreach($checks as $key => $value) {
$table[] = sprintf('<th>%1$s</th><td>%2$s</td>',$key,$value);
}
?>
<html>
<head>
<style type="text/css">
body {font-family:helvetica,sans-serif;font-size:1em}
table {border-collapse:collapse;font-family:inherit;font-size:inherit}
th,td {padding:.5em;border:.1em solid #ccc}
th {text-align:left}
td {text-align:center}
.yes {color:#090}
.no {color:#f00}
</style>
</head>
<body>
<table>
<tr><?php echo implode("</tr>\n\t\t\t<tr>",$table); ?></tr>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment