#! /usr/bin/perl -w
use strict;
use GD;
use GD;
# create a new image
my $im = new GD::Image(110,100) || die;
# allocate some colors
my $red = $im->colorAllocate(255,0,0);
my $blue = $im->colorAllocate(0,0,255);
# Put a blue frame around the picture
$im->rectangle(0,0,109,99,$blue);
# and fill it
$im->fill(110,100,$red);
# Draw a blue oval
$im->filledEllipse(50,55,95,75,$blue);
# draw a line
my $red_brush = new GD::Image(4,4);
my $bred = $red_brush->colorAllocate(196,0,0);
$red_brush->fill(0,0,$bred);
$im->setBrush($red_brush);
$im->line(30, 60 , 70, 60, gdBrushed);
$im->line(30, 40 , 35, 40, gdBrushed);
$im->line(60, 40 , 65, 40, gdBrushed);
# write some stuff:
$im->string(gdLargeFont, 20 , 5, "Be Happy!", $blue);
# Convert the image to PNG and print it on standard output
open(P,">example.png") or die;
# make sure we are writing to a binary stream
binmode P;
print P $im->png;