#!/usr/bin/perl -w
use strict;

use CGI qw( header );
use GD;

my($cgi) = CGI->new();
my($img) = GD::Image->new(300,300);

my($sixteen) =
   [
      [255,255,255], [000,000,000], [000,000,128], [000,000,255],
      [000,128,000], [000,128,128], [000,255,000], [000,255,255],
      [128,000,000], [128,000,128], [128,128,000], [128,128,128],
      [192,192,192], [255,000,000], [255,000,255], [255,255,000],
   ];

foreach (@$sixteen) { $img->colorAllocate(@$_) }

shift(@$sixteen);

for (my($i) = 0; $i < @$sixteen; ++$i) {

   $img->string
      (
         gdGiantFont,
         20, (($i + 1) * 15),
         q[Hello World!],
         $img->colorExact(@{ $$sixteen[$i] }),
      )
}

print($cgi->header('img/gif'));

binmode(STDOUT);

print($img->png()) and exit;