#!/usr/bin/perl -w use strict; use GD; my ($width, $height) = (300,50); my ($rvalue, $gvalue, $bvalue, $total) = (255,255,255,256); my $im = new GD::Image($width,$height); #Allocate the colors that are going to be used my @colors; for (0..255) { $colors[$_] = $im->colorAllocate(int(rand($rvalue)),int(rand($gvalue)),int(rand($bvalue))); } # Create image according to height/width proportions and given amount of colors for my $width_length (0..$width-1) { for my $height_length (0..$height-1) { $im->setPixel($width_length,$height_length,$colors[int(rand($total))]); } } # Set binmode to STDOUT binmode STDOUT; # Set output to be an image for CGI print "Content-Type: image/png\n\n"; # Standard output of created image print $im->png;