my $mask = Image::Magick->new; my $background = Image::Magick->new; my $foreground = Image::Magick->new; $mask->Read("mask.png"); $background->Set(size=>'500x500'); $background->Read("xc:white"); $foreground->Read("foreground.jpg"); $background->Composite(compose=>'Dissolve', opacity => '87.8', image=>$foreground); $background->Composite(image=>$mask); $background->Write("output.jpg");