Re: Compositing transparent png over image using Magick++ GraphicsMagick API

Dragan Jotanovic <[email protected]> Wed, 29 Jan 2014 11:03:05 +0000
Newsgroups gmane.comp.video.graphicsmagick.apis
Message-ID <CAJSsW4qJaHA7VayLO5oQfuR6ObdNTY-vvqRzc0shWuFk34UXLA@mail.gmail.com>
Thanks Bob, that's good to know, but I'm still struggling to get this
working.

Here's better example. From command line I create transparent png
containing watermark like so:

*gm convert -background none -fill white -font Ravie -pointSize 36 label:A
watermark.png*

Then if I execute:

*gm composite -gravity center watermark.png   rose:   destination.gif*

I get picture of rose that is overlayed with letter A (transparency from
watermark image preserved).

How to write this command in Magick++?

I tried:

*    Image rose("magick:rose");*
*  Image watermark("watermark.png");*
*  rose.composite(watermark, CenterGravity, CopyCompositeOp);*
*  rose.write("destination.gif");*

but I get black pixels in place of transparent pixels from watermark.png.
I also tried setting rose.matte(true); and watermark.matte(true); without
results.

Is there an easy way to accomplish this?

Dragan



On Tue, Jan 28, 2014 at 10:36 PM, Bob Friesenhahn <
[email protected]> wrote:

> On Tue, 28 Jan 2014, Dragan Jotanovic wrote:
>
> > Thanks for the quick response.I'm not trying to create transparent jpeg,
> I'm trying to compose transparent png onto an image,
> > so that only non-transparent pixels are composed.
> > For example, when I execute this from command line:
> > gm compose watermark.png source.jpg destination.jpg
> > I get the desired effect. Only non-transparent pixels from png image are
> composed to destination image.
> > What I'm interested in is how to achive this with magick++ api?
>
> Anything creatable at the command line can be done via the Magick++
> API.  You are using DissolveCompositeOp but the default composition
> operator (from your command-line example) would be CopyCompositeOp.
>
> You can make an originally opaque image support transparency by using
> image.matte(true);.
>
> Bob
> --
> Bob Friesenhahn
> [email protected], http://www.simplesystems.org/users/bfriesen/
> GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
>
>
> ------------------------------------------------------------------------------
> WatchGuard Dimension instantly turns raw network data into actionable
> security intelligence. It gives you real-time visual feedback on key
> security issues and trends.  Skip the complicated setup - simply import
> a virtual appliance and go from zero to informed in seconds.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
> _______________________________________________
> Graphicsmagick-apis mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/graphicsmagick-apis
>

------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk

_______________________________________________
Graphicsmagick-apis mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-apis