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


In reply to Image compositing with opacity not working in perlmagick by skullcap23

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.