I'm trying to draw a semi-transparent block onto an existing image using Perl's GD.pm.
My code looks like this:
use strict;
use GD;
my $img = GD::Image->new('cello.png');
GD::Image->trueColor(1);
$img->saveAlpha(1);
my $boxColor = $img->colorClosestAlpha(0,0,0,60);
$img->filledRectangle(0,300,600,400, $boxColor);
open(FH, '>', 'cello2.png') or die $!;
binmode FH;
print FH $img->png();
close FH;
This draws a black box on the image, but the box is completely opaque as if the alpha channel is being ignored. Any suggestions would be greatly appreciated.
check this code.