in reply to Image::Magick

The code below should do the trick.
However, I'm looking for a way to make the image over transparent to 50%. It doesn't seem to work with the 'Over' compose method. The only way to do it would be to create a PNG with an alpha transparency set to 50%, but I can't find a way to make one with Image::Magick or GD. Has anyone have an idea?

$image_over->Read("over.gif"); $image_under->Read("under.jpg"); $image_over->Transparent("white"); # Set the transp. color $image_under->Composite( compose => 'Over', opacity => 50, # Doesn't seem to work with 'Over' x => 20, y => 25, image => $image_over, ) ; $image_under->Write("Composite.jpg");
<kbd>--
PerlMonger::Paris(http => 'paris.pm.org');</kbd>

Replies are listed 'Best First'.
Re: Re: Image::Magick
by merlyn (Sage) on Dec 03, 2000 at 21:39 UTC
    The ImageMagick documentation is quite... unimpressive.

    Having said that, I stared at http://www.simplesystems.org/ImageMagick/www/combine.html for a few minutes and decided that I would suggest using "atop" rather than "over", for no apparent reason other than that's the way I always am forced to work with ImageMagick... trial and error. {grin}

    It's so sad that such a great tool has such lousy documentation. I've used it for only a half dozen tasks or so, and three times have had to go to the source code to get my answer for simple things.

    -- Randal L. Schwartz, Perl hacker

      I cannot believe that--after weeks of sweat--I came to nearly the same conclusion as a Perl icon.

      ("Nearly", because without Mr. Schwartz's deep-and-wide experience, I could not recognize that the documentation was "unimpressive." I thought it "sucked.")

      I had come to the same conclusion that the PerlMagick module (a depressingly confusing synonym for Image::Magick) is best designed for "trial and error."

      Here's the thing: what I have always loved-loved-loved about Perl is that when I know what I want to do, there's Perl, right there with more than one way to do it. I know what I want to do with Image::Magick--and that isn't helping much at all.

      I'll ask it in a new ticket, but what I'd like to do is interrogate the Image::Magick module, and whatever is associated with it (however that's done) and ask it to spit out Just What Methods I can use, and Just What Parameters they take.

      Thank you Mr. Schwartz. Your comment here gives me new hope that I maybe ain't crazy. (And thanks for the PP book--which I paid retail for, probably back when it cost about-seven-fifty. Sorry I'm late with the thanks, but I had no idea how to get ahold of you.)

Re: Re: Image::Magick
by Anonymous Monk on Dec 04, 2000 at 18:45 UTC

    Update: Actually, I've found the way to achieve the effect I wanted, so if anyone's interrested, here's the code you have to add just before the call to Transparent:

    $CD_map->MatteFloodfill( x => $x_inside, y => $y_inside, matte => 90);

    Where $x_inside and $y_inside are the coordinates of a point inside the polygone you want to make translucid. the value of matte is set to 90 here, but it seems to be more or less the same than 50% transparency...

    Anyway, it's a real good way to dynamically paint area in a graphic file, once the hassle of compiling Image::Magick for Win32 is finished!