PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Code: Select all
@$image = ();
$x = $image->Read('pshadow.png');
warn "$x" if "$x";
$x = $final->Composite(compose=>'over', image=>$image);
This is the relevant portion. $final is the image I intend to write out, but both images have transparent portions. $image, which I'm attempting to lay over the top of the final, only does so on those portions where a mask from a previous composite allows. How can I force this to use $image's alpha channel as a mask? If I cook up such a mask in Gimp, and manually use that, it works as expected, but this is a little obtuse, and I have too many utility images already to be adding another one without good reason.
Any help appreciated, thanks in advance.
Have I not supplied enough information? Not the correct information? Have I described my problem poorly?
If I simply load $final, and then composite $image over the top of it (and nothing else before that), this works as expected. Unfortunately, I've completed several other composites and resizes prior to this.
I thought that it might be that I was re-using image, as I loaded several different files, and then composited them together. But giving this it's own new IM object, and using it only to load the one file, no effect. Still doesn't work.
So it's screwy because $final isn't fresh somehow. Short of writing it out to file, and re-opening it with a new variable, is there any way to make this work?
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
composite requires at least two images, the destination or background image ($final) and the source or overlay image ($image). Both need to be defined, even if one is not used (Src, Dst, Clear compose methods).
Usally if you want to keep your original destination image, you would make a clone of it first.