I've never used Imager before :)
This seems to work
#!/usr/bin/perl --
use strict;
use warnings;
use Imager;
# setting Imager::Color->new($red, $green, $blue, $alpha);
my $blue = Imager::Color->new( 0, 0, 255, 255);
my $red = Imager::Color->new( 255, 0, 0, 63);
my $canvas_blue = Imager->new(xsize=>700, ysize => 500, channels => 4)
+;
$canvas_blue->box(color => $blue, xmin=>10, ymin=>30, xmax=>200, ymax=
+>300, filled=> 1);
my $canvas_red = Imager->new(xsize=>700, ysize => 500, channels => 4);
$canvas_red->box(color => $red, xmin=>50, ymin=>80, xmax=>250, ymax=>3
+50, filled=> 1, alpha => 1);
my $outfile = "foo.png";
# overlay
$canvas_blue->rubthrough( src => $canvas_red );
$canvas_blue->write(file=>$outfile) or die $canvas_blue->errstr;
canvas,
overlay,
alpha, Imager::Transformations |