in reply to Creating transparent images using Imager

I don't think that Imager will mix the images according to their transparency as long as you use the built-in commands. I think if you want proper bitmap mixing according to the transparency, you need to draw the bitmaps into separate Imager canvasses and then overlay the two canvasses.

  • Comment on Re: Creating transparent images using Imager

Replies are listed 'Best First'.
Re^2: Creating transparent images using Imager
by hilitai (Monk) on Apr 27, 2009 at 14:50 UTC
    Thanks... if you know how, could you perhaps express "draw the bitmaps into separate Imager canvasses and then overlay" as a few lines of Perl?
      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
        That is just what I am looking for. Thanks very much.