I'm trying to put overlay (watermark) on base image. Assuming it looks like this:
opaque rectangle with "fully transparent" text on it. I.e. all pixels of text is transparent, as well as background under it.
1 way:
I do opacity 60% in Photoshop:
And just compose it in code:
MagickWand* overlay = NewMagickWand();
MagickReadImage(overlay, overlaypath);
MagickCompositeImage(wand, overlay, OverCompositeOp, 100, 100);
//all open/destroy code is omitted
And result is rectangle is semi-transparent while text is fully transparent:
So far so good, but I also wanted to regulate overlay opacity via application config, so I tried second way:
2 way:
100% in Photoshop (as on very first image in this post) and trying to set transparency via MagickWand:
MagickReadImage(overlay, overlaypath);
MagickSetImageOpacity(overlay, 0.6);
MagickCompositeImage(wand, overlay, OverCompositeOp, 100, 100);
Result is totally blank rectangle, semi-transparent though
It looks like MagickSetImageOpacity
set up every pixel alpha channel to the same 0.6 value regardless of its current value. What I need is currentAlpha -= givenAlpha
for every pixel of overlay
wand. Is this possible without iterate every wand pixel by hand?