Page 1 of 1

MagickWand equivalent of -channel RGBA

Posted: 2012-12-18T06:41:56-07:00
by J2T
Hi guys,

i'm looking for the equivalent of the -channel RGBA command line option.

The reason is that i like to blur a image with transparency information. I get the same result as described here with the yellow circle with the black creeping pixels at the outline.

So how i can apply the -channel RGBA with MagickWand to fix that?

Thanks!

Re: MagickWand equivalent of -channel RGBA

Posted: 2012-12-18T13:27:22-07:00
by el_supremo
I think that the MagickWand equivalent is:

Code: Select all

MagickSetOption(magick_wand,"channel","RGBA")
Pete

Re: MagickWand equivalent of -channel RGBA

Posted: 2012-12-19T06:05:01-07:00
by J2T
Thanks Pete for your reply.

I call this right before MagickBlurImage() but it doesn't work as my test image still has the creeping black pixels.

Re: MagickWand equivalent of -channel RGBA

Posted: 2012-12-19T07:08:13-07:00
by J2T
I tried to find a workaround but always get stuck. Maybe some of you can help me out with this?!

(I use c# + P/Invoke and my test image is a yellow square on a transparent background)

1.

Code: Select all

 IntPtr newWand = MagickMergeImageLayers(image, ImageLayerMethod.FlattenLayer);
MagickBlurImage(newWand, 0.0, 8.0);
with the result, that the blur is correct (because of the white color of the transparent pixels i guess) but the background is white (alpha=1/255). But i like to have a full transparent background. How can i achieve this?

2.

Code: Select all

MagickSetImageBackgroundColor(image, color);
MagickBlurImageChannel(image, ChannelType.AllChannels, 0, 8);
with this result. This is what i want. Nice blur with transparent background. The problem here is that MagickSetImageBackgroundColor() does not have any influences. So how i can change the color here? (at another point i use MagickSetImageBackgroundColor() in combination with MagickShadowImage() which works fantastic)

Thanks for any advice!

Cheers,
Florian

Re: MagickWand equivalent of -channel RGBA

Posted: 2012-12-19T09:08:36-07:00
by J2T
Got it!

Code: Select all

MagickNewImage(coloredBG, width, height, color);
MagickBlurImageChannel(image, ChannelType.AllChannels, 0, 8);
MagickCompositeImage(coloredBG, image, CompositeOperator.CopyOpacityCompositeOp, 0, 0);

Re: MagickWand equivalent of -channel RGBA

Posted: 2012-12-19T09:10:11-07:00
by el_supremo
Don't know if this will work but try:

Code: Select all

MagickSetBackgroundColor(image, color);
instead of MagickSetImageBackgroundColor.

Pete
P.S. I see you've just got a solution. Try this anyway :-)

Re: MagickWand equivalent of -channel RGBA

Posted: 2012-12-19T09:33:02-07:00
by J2T
No, that doesn't work either.

Thanks for your suggestions :)