如何在ImageMagick中绘制文本并对其进行阴影?
我正在使用转换在图像上打印一些文本,并且想用黑色阴影装饰文本,我尝试了 -blur 或-高斯,但我不能应用于文本,它仅应用于背景图像。
我需要使用 -draw 命令而不是-批注。
I'm printing some text on an image with convert and I would like to decorate the text with a black shadow, I tried -blur or -gaussian but I cannot apply to the text, it is applied to the background image only. I need to use -draw command and not -annotate.
这是代码我需要更新阴影
And this is the code I need to update for shadowing
-font "geometricslab703bt-bold-webfont.ttf" -fill White -pointsize 18 -draw "rotate -4 text 350,250 '---- mijn ideale ----'"
请提前谢谢
一种更好,更灵活的使用文本阴影的方法是在新图层上渲染阴影。使用此方法,您可以根据需要操纵阴影文本,而不会影响背景。调整任何几何偏移后,最后在阴影顶部绘制实际文本。例如:
A better, more flexible, way to work with text shadow is to render the shadow on a new layer. This method will allow you to manipulate the shadow-text, as needed, without affecting the background. Finally draw the actual text on top of the shadow after adjusting any geometric offsetting. Here's an example:
convert -size 280x100 pattern:SMALLFISHSCALES \
\( xc:transparent -font "Menlo" -pointsize 32 -fill black -draw "rotate -4 text 20,60 'ImageMagick'" -blur 0x1 \) \
-geometry +2+2 -composite \
-font "Menlo" -fill white -pointsize 32 -draw "rotate -4 text 20,60 'ImageMagick'" \
example.png
逃脱的括号 \(\)
将创建一个新的子图像;其中,将使用 -composite
标志应用于背景。
The escaped braces "\( \)
" will create a new sub-image; which, will be applied to the background with -composite
flag.
此解决方案的劳动强度更高,但可以保留您所有的资源效果隔离。
This solution is a little bit more labor intensive, but keeps all your effects isolated.