Gd php?

software development


I’m a newbie at PHP. I’m trying to get the GD imaging library to work for the CAPTCHA routine of an open source Guest Book. The images turn out empty. Can someone supply a PHP code snippet that would demonstrate that the GD library on Dreamhost actually works?

Here is a link to the Guest Book webpage:


Sure!<?PHP if (imagetypes() & IMG_GIF) echo "GIF Support is enabled<br />"; if (imagetypes() & IMG_JPG) echo "JPEG Support is enabled<br />"; if (imagetypes() & IMG_PNG) echo "PNG Support is enabled<br />"; if (imagetypes() & IMG_WBMP) echo "WBMP Support is enabled<br />"; ?> Lot’s more qucik little snippets at this great resource:



They do work because I use them to create this image daily.

Check through the PHP code to see if any fonts are used and if so if the code is pointing to those fonts.

For example if you were using Vera.ttf you would use:-


If it is a font that you uploaded to work with the captcha php the same would apply. Check the path to the font or images.


Opinions are my own views, not DreamHosts’.
I am NOT a DreamHost employee OK!! :@

You act on my advice at your own risk!


To answer my own question, try browsing to a page containing (only) this code, in a file with extension .php (substituting your own font):

// Set the content-type
header(“Content-type: image/png”);

$height = 43;
$width = 160;
$font = ‘guestbook/fonts/captcha.ttf’;

$image_p = imagecreate($width, $height);

$black = imagecolorallocate($image_p, 0, 0, 0);
$grey = imagecolorallocate($image_p, 128, 128, 128);

imagefilledrectangle($image_p, 0, 0, $width - 1, $height - 1, $grey);

imagettftext($image_p, 22, 0, 10, 30, $black, $font, “Hello, World!”);




It works for me -> :wink: