use Imager; $img = Imager->new(xsize=>700, ysize => 500, channels => 4); # setting Imager::Color->new($red, $green, $blue, $alpha); $blue = Imager::Color->new( 0, 0, 255, 255); $red = Imager::Color->new( 255, 0, 0, 63); $img->box(color => $blue, xmin=>10, ymin=>30, xmax=>200, ymax=>300, filled=> 1); $img->box(color => $red, xmin=>50, ymin=>80, xmax=>250, ymax=>350, filled=> 1); my $outfile = "foo.png"; $img->write(file=>$outfile) or die $img->errstr;