Hi, I think I found the answer for you. Change 'Dissolve' to 'Atop'. The following script works here like the shell version.

P.S. Don't feel like a dunce, I seem to remember spending a few hours trying every compose type when I discovered this a few years back. :-) I changed a few filenames and lowered the opacity for clarity.

#!/usr/bin/perl use warnings; use Image::Magick; use strict; #From the command line, this is the result I'd like to achieve: # composite -dissolve 87.8 foreground.jpg -size 500x500 xc:white outpu +t.jpg; # composite mask.png output.jpg output.jpg my $mask = Image::Magick->new(magick=>'png'); my $background = Image::Magick->new(magick=>'png'); my $foreground = Image::Magick->new(magick=>'png'); $mask->Read("png:zzzmask.png"); $background->Set(size=>'500x500'); $background->Read("xc:white"); $background->Set(magick=>'png'); $foreground->Read("zzzforeground.jpg"); $foreground->Set(magick=>'png'); $background->Composite(compose=>'Atop', image=>$foreground, opacity => + '50.8%' ); $background->Composite(image=>$mask); $background->Write("zzzpoutput.png"); exit; # The mask can be any png with transparency (any kind of watermark), # and foreground any 500x500 image.

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re: Setting opacity with dissolve in perlmagick by zentara
in thread Setting opacity with dissolve in perlmagick by shohn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.