skullcap23 has asked for the wisdom of the Perl Monks concerning the following question:
I've been writing a program using imagemagick which makes animated tiled background gifs of lots of objects falling (originally to make a snow effect but it could be anything). I'd like to have them all rendered in different random opacities over the background to get a layered effect, but I can't get the opacity function to work in Image->composite.
I've reproduced the error in the following code (adapted from an earlier reply i found on a similar subject.)
#!/usr/bin/perl -w use strict; use Image::Magick; # Simulate background picture... :) my $image1 = Image::Magick->new; $image1->Set(size=>'100x100'); $image1->ReadImage('xc:orange'); # Textbackground image my $image2 = Image::Magick->new; $image2->ReadImage('testopaq.png'); # Make composite image of background and a 50 % transparent image. $image1->Composite(compose=>'over', image=>$image2, x=>0, y=>0, opacity=>50 ); $image1->Display;
testopaq.png is a black stripe and a white stripe on a transparent background.
with opacity=0 or not stated, it does the normal 'over' overlay, with transparent areas untouched, but with opacity >0, testopaq.png is overlaid with a black background and no effect on opacity. The transparent areas of testopaq.png end up black.
when i use the 'dissolve' option instead of 'over', nothing happens at all, for any value of opacity.
using ImageMagick 5.5.5 and perl 5.6.1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Image compositing with opacity not working in perlmagick
by halley (Prior) on Jun 02, 2003 at 18:49 UTC | |
by skullcap23 (Initiate) on Jun 02, 2003 at 23:35 UTC |