Here's the Perl code I'm running:
Code: Select all
#!/usr/bin/perl
use Image::Magick;
$base = Image::Magick->new;
$base->Set(size=>"400x300");
$base->Read("sign01-base.png");
$tint = Image::Magick->new;
$tint->Set(size=>"400x300",matte=>'True');
$tint->Read("xc:#2C8259");
$mask = Image::Magick->new;
$mask->Set(size=>"400x300");
$mask->Read("sign01-header-bg-mask.gif");
$base->Composite(image=>$tint,compose=>'Over',mask=>$mask,x=>0,y=>0,gravity=>'NorthWest');
undef $mask;
# the following line works under Linux but causes Perl to crash under Windows XP
$base->Set(mask=>"");
$overlay = Image::Magick->new;
$overlay->Set(size=>"400x300");
$overlay->Read("sign01-overlay.png");
$base->Composite(image=>$overlay,compose=>'Over',x=>0,y=>0,gravity=>'NorthWest');
undef $overlay;
print "Content-Type: image/jpeg;\n\n";
binmode STDOUT;
$base->Set(compression=>'JPEG',quality=>'85');
$base->Write('jpg:-');
undef $base;
This version demonstrates the persistent masking behavior (it doesn't use the Set(mask=>"") line); this version demonstrates shows what happens when Set(mask=>"") is used. This is the base image, this is the mask image, this is the overlay image.