shohn has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I'm trying to overlay 3 images using the Image::Magick module but I'm having trouble achieving the desired result. I have a background image (pure white background created on the fly), a foreground image (a jpeg I read from a file, which I want to overlay onto the background with an opacity of 87.8%) and a mask (a png with transparency) that overlays the whole thing.
From the command line, this is the result I'd like to achieve:
I've written some code in perl using Image::Magick which looks like this:composite -dissolve 87.8 foreground.jpg -size 500x500 xc:white output. +jpg; composite mask.png output.jpg output.jpg
my $mask = Image::Magick->new; my $background = Image::Magick->new; my $foreground = Image::Magick->new; $mask->Read("mask.png"); $background->Set(size=>'500x500'); $background->Read("xc:white"); $foreground->Read("foreground.jpg"); $background->Composite(compose=>'Dissolve', opacity => '87.8', image=> +$foreground); $background->Composite(image=>$mask); $background->Write("output.jpg");
For some reason the opacity is being ignored (changing the background image from white to red, or blue, has no effect on the image). Any help would be appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Setting opacity with dissolve in perlmagick
by zentara (Cardinal) on May 28, 2012 at 10:32 UTC | |
by shohn (Novice) on May 28, 2012 at 10:47 UTC | |
|
Re: Setting opacity with dissolve in perlmagick
by zentara (Cardinal) on May 28, 2012 at 13:07 UTC | |
by shohn (Novice) on May 28, 2012 at 13:34 UTC |