If you've spent time around the Internet, you've likely seen various kinds of image verification when you fill out forms, sometimes referred to as CAPTCHA ("Completely Automated Public Turing test to tell Computers and Humans Apart"). Sometimes they are simply referred to as Turing numbers, named after Professor Alan Turing.
Image manipulation can also be used for other beneficial, or even humorous ways by imprinting text or another image into an image. If the script being run is PHP, there is a good chance it is using the GD library to accomplish this feat.
How do you test your server for GD support? Testing for a GD package installation can be done using the PHP
gd_info function. Below is the code to test this on your own server.
<?
print '<p style="color: #303030; font-size: 22;">GD is ';
if (function_exists("gd_info")) {
print '<span style="color: #00AA00; font-weight: bold;">supported</span> by your server!</p>';
$gd = gd_info();
foreach ($gd as $k => $v) {
print '<div style="width: 340px; border-bottom: 1px solid #DDDDDD; padding: 2px;"><font size="2" face="Verdana, Arial, Helvetica">';
if ($k == "GD Version") {
print '<span style="float: left;width: 300px;">GD Installed</span> ';
} else {
print '<span style="float: left;width: 300px;">' . $k . '</span> ';
}
if ($v)
print '<span style="color: #00AA00; font-weight: bold;">Yes</span>';
else
print '<span style="color: #EE0000; font-weight: bold;">No</span>';
print '<div style="clear:both;"><!-- --></div></div>';
}
} else {
print '<span style="color: #EE0000; font-weight: bold;">not supported</span> by your server!</p>';
}
print '</div>';
?>
|
Simply save this to your website and give it a spin to find out whether your server supports GD. You may also view a demo of how it looks on our server,
here.
We hope this tutorial has proved helpful for you.
To view others, simply return
home to browse our various PHP tutorials.