Re: draw semitransparent text on semitransparent background image looks strange

Bob Friesenhahn <[email protected]> Fri, 7 Dec 2018 08:11:10 -0600 (CST)
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
On Fri, 7 Dec 2018, yzh卯帽潞锚 wrote:

> hi,
>
> I try to draw some text on semitransparent PNG with text opacity set, and unwanted text border outcome makes the result image look strange.
>
> This phenomenon can be reproduced use the following command:
>
> gm convert -size 500x500 'xc:#fff3' test.png
> gm convert -fill "#000a" -pointsize 60 -draw "text 100,100 test" test.png test_1.png

Without taking the time to experiment to find the best solution, I 
will mention that it is best to do all drawing within a single -draw 
command (without relying on separate options like -pointsize and 
-fill) and that there are many more drawing primitives available than 
are currently included in the formal documentation (I should update 
the documentation).  Primitives can simply be listed one after another 
in the drawing command.

I have written notes regarding the currently supported drawing 
commands (known as "Magick Vector Graphics", MVG) which may be viewed 
at:

https://sourceforge.net/p/graphicsmagick/code/ci/default/tree/Magick++/drawing-primitives.txt

In particular, you will see that there are several options which 
pertain to what you are doing, including these:

fill colorspec
fill-opacity opacity[%]
stroke colorspec
stroke-antialias truth-value (0 or 1)
stroke-opacity opacity[%]
stroke-width linewidth
text-antialias (0|1)

I think that you should use opaque fill/stroke color specifications 
and then specify 'fill-opacity' and/or 'stroke-opacity' as required.

The drawing commands are intending to satisfy SVG drawing requirements 
so studying the SVG specification will help.

As usual, there is no warranty. :-)

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
Public Key,     http://www.simplesystems.org/users/bfriesen/public-key.txt

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