On Fri, 31 Oct 2008 06:57:25 -0700
"Min Yan" <[EMAIL PROTECTED]> wrote:

>Hi,
>
>      I am using Perl ImageMagick.  I first draw a black line using Draw
>method.  Then I set the green to be transparent using,
>
>       $image->Transparent(color=>'green');
>
>      Then I Draw a green rectangle on top of the line.  But the line
>cannot be seen, which means the green rectangle is not transparent.  Can
>anyone help?

Fred Winehous is right, you need to draw the line after the rectangle.
Look at this script.
Some things to notice. 

The setting of the transparent green must be done after
the rectangle was drawn.

You may need to open the output in Gimp to see the transparent rectangle,
some viewers will show it as black.

When you draw the rectangle you overwrite the line, and the line will not 
magically
reappear when you make the green transparent. To do that sort of thing, you 
need to
work on a Canvas type widget that supports transparency, and persistence of 
items
in layers. See http://perlmonks.org?node_id=695452 for the general idea. The 
Tk::Zinc
canvas, the Gnome2::Canvas, and the Goo::Canvas are Perl widgets that allow you 
to do
what you want.  


#!/usr/bin/perl -w
use strict;
use Image::Magick;

my $image = Image::Magick->new;
$image->Set(size=>'170x100');
my $rc = $image->Read("xc:white");

$image->Draw(primitive=> 'line',fill=>'red', points=>'0,0 110,70');
$image->Draw(primitive=> 'rectangle',fill=>'green', points=>'60,30 90,60');
$image->Transparent('color' => 'green');

# another way to do it transparency
#$image->Mogrify('transparent-color' => 'green');

$image->Write("output.png");

__END__

zentara

-- 
I'm not really a human, but I play one on earth.
http://zentara.net/Remember_How_Lucky_You_Are.html 
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to