iterating over the image can change the alpha then.
#!/usr/bin/perl
use strict;
use warnings;
use Image::Imlib2;
my $bg = Image::Imlib2->load("pens.png");
my @files=("blue.png", "red.png");
my @mix=(255,192,128,64,0);
my $clone_bg;
for (my $i=0;$i<=4;$i++){
$clone_bg=$bg->clone;
blend($files[0],$mix[$i]);
blend($files[1],255-$mix[$i]);
$clone_bg->save("iterated_$i.png");
}
sub blend{
my($file,$new_alpha)=@_;
my $image=Image::Imlib2->load($file);
$image->will_blend(0);#need this to be 0
$image->has_alpha(1);
my $width = $image->width;
my $height = $image->height;
for my $y (0 .. $height - 1) {
for my $x (0 .. $width - 1) {
my ($red, $green, $blue, $alpha) = $image->query_pixel($x, $y);
unless ($alpha==0){
$image->set_colour($red, $green, $blue, $new_alpha);
$image->draw_point($x, $y);
}
}
}
$image->will_blend(1);
$clone_bg->blend($image,1 , 0, 0, $width, $height, 0, 0, $width, $height);
undef $image;
return;
}