Feather Images Using Blur translating example to C++

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
rydzak
Posts: 1
Joined: 2016-09-19T02:43:35-07:00
Authentication code: 1151

Feather Images Using Blur translating example to C++

Post by rydzak » 2016-09-19T03:03:20-07:00

Hello. I am trying to convert the example on the webpage http://www.imagemagick.org/Usage/thumbnails/#rounded to work in Magick++.

I am trying to produce a halo type image (that will be composited with the original image) to provide a transparent, rounded edge "glow" surrounding the original image. These are the only examples that I have found that looks like what I am trying to accomplish. BUT, if there is an easier way to get a rounded edge, transparent glow for an image, I would love to know how to make it! :D

Here is the command line that I am trying to convert:
convert thumbnail.gif -alpha set -virtual-pixel transparent \
-channel A -blur 0x8 -level 50%,100% +channel soft_edge.png

Here is the other one that I also tried:
convert thumbnail.gif -alpha set -virtual-pixel transparent -channel A \
-blur 0x8 -threshold 50% +channel rounded_corner_blur.gif

Here is the code that I am using and I am not able to get it to blur (chop off) the edges (as shown on the webpage listed above):

Magick::Image haloImage;
haloImage = mImage; // mImage gets passed into this function. it is a .png of varying shapes (all with size ~ 64x64 pixels)
auto haloColor = Magick::Color(0xFFFF, 0xCCCC, 0x0000, 0x8888);
haloImage.fillColor(haloColor);
haloImage.colorize(100, haloColor);
haloImage.backgroundColor(haloColor);

haloImage.virtualPixelMethod(Magick::TransparentVirtualPixelMethod);
haloImage.alphaChannel(Magick::AlphaChannelType::SetAlphaChannel);
haloImage.blurChannel(Magick::AlphaChannel, 0.0, 50.0);
//haloImage.threshold(50.0); --> tried this when setting the colors above to black and it didn't slice off the corners as expected
//haloImage.levelChannel(Magick::AlphaChannel, .5, 1.0); // another attempt that was unsuccessful.

Any help to convert these samples into working C++ would be GREATLY appreciated. I really appreciate all the examples on the web for use with ImageMagick. I find it kind of tricky sometimes to know what the options translate to in the C++ code, however to achieve the exact same results.

thank you!

-Carol

Post Reply