Code: Select all
use Image::Magick;
#use strict; # im.test.transparent.png.pl 2>&1 | grep -v "explicit package na"
$quanta=8; # 8 bits should do
$xyres='1200x800';
$ifn='hueg2.png';
$im = Image::Magick->new(size=>$xyres, depth=>$quanta);
$ie = $im->Set(alpha=>'Transparent');
$ie = $im->Read("xc:transparent"); # Color NONE == rgba(0, 0, 0, 0.0)
warn "$ie" if "$ie";
$ie=$im->Color(color=>"rgba(0,0,0,0.0)"); # "Color" whole img transparent!
warn "$ie" if "$ie";
$ie=$im->Draw(primitive=>'rectangle', points=>"2,2 1198,798",
stroke=>"rgba(2,0,255,1.0)", fill=>'none');
warn "$ie" if "$ie";
$ie = $im->Write(filename=>"PNG:$ifn");
warn "$ie" if "$ie";
printf("HG: IM=%s, xyres=$xyres, img=$ifn\n", $im);
undef $im;
- D:\music>identify hueg2.png
hueg2.png PNG 1200x800 1200x800+0+0 8-bit sRGB 1.92KB 0.000u 0:00.000
Brian