ImageMagick 示例 --
复合字体效果
- 索引
-
ImageMagick 示例前言和索引
-
复合字体
以各种样式绘制文本作为图像
-
使用蒙版图像与字体
在叠加之前移除图像的部分
-
高级字体处理
扩展字体以产生更复杂的结果
复合字体效果
普通的文本作为图像很无聊,但只需很少的努力,你就可以叠加和着色文本,从而产生一些非常奇怪和奇妙的效果。为此,我们需要多次绘制文本,叠加不同的图案和颜色,并应用许多可用的图像操作符,以从原始的、无聊的文本生成更有趣的特殊效果。请注意,这些效果中的许多都可以应用于除基本字体之外的其他图像,例如我们正在使用的图像。特别是,您可以将效果应用于剪贴画图像。 平铺字体:您不限于以固定颜色绘制字体。您可以在字体上使用平铺图案。
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -tile pattern:checkerboard -annotate +28+68 'Anthony' \ font_tile.jpg |
![[IM Output]](font_tile.jpg)
-tile
”设置会覆盖“-fill
”颜色用于“-draw
”操作符。![]() ![]() |
从 IM v6.3.2 开始,您可以使用“-fill ”设置指定平铺图像,但是不建议使用此用法,因为许多使用“-fill ”颜色的操作符将无法理解平铺图像,并默认为使用“黑色”。 |
-tile
”图像之前指定“-origin
”设置。图像会根据在将其分配为填充平铺时指定的量进行滚动。 渐变字体:使用的平铺不必很小,也可以是整个画布的大小。
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -tile gradient: -annotate +28+68 'Anthony' \ font_gradient.jpg |
![[IM Output]](font_gradient.jpg)
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill Navy -annotate 180x180+300+35 'Anthony' \ font_upsidedown.jpg |
![[IM Output]](font_upsidedown.jpg)
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill black -draw "text 28,68 'Anthony'" \ -fill white -draw "text 25,65 'Anthony'" \ font_shadow.jpg |
![[IM Output]](font_shadow.jpg)
-annotate
”字体绘制操作符可以分别旋转垂直维度和水平维度,因此您可以指定一些奇特的旋转“倾斜”或“剪切”字体。这非常适合制作奇怪的阴影,或制作您自己的斜体或倾斜字体。
magick -size 320x115 xc:lightblue -font Candice -pointsize 72 \ -fill Navy -annotate 0x0+12+55 'Anthony' \ -fill RoyalBlue -annotate 0x130+25+80 'Anthony' \ font_slewed.jpg |
![[IM Output]](font_slewed.jpg)
-draw
”来倾斜您的字体,尽管这有点棘手,因为它涉及额外的 MVG(Magick 矢量图形)操作来扭曲绘图表面。由于表面正在被扭曲,因此最好先使用“translate
”设置字体位置,然后再进行扭曲。
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill Navy -draw "translate 28,68 skewX -20 text 0,0 'Anthony'" \ font_slanted.jpg |
![[IM Output]](font_slanted.jpg)
![]() ![]() |
“-annotate ”和“-draw skew? ”操作实际上都旋转了绘图表面的 X 和 Y 轴。这与对现有图像使用“-shear ”的效果不同,后者会延长图像的剪切轴,因此图像的高度(或宽度)不会因操作而改变。 |
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill black -annotate +24+64 'Anthony' \ -fill white -annotate +26+66 'Anthony' \ -fill lightblue -annotate +25+65 'Anthony' \ font_stamp.jpg |
![[IM Output]](font_stamp.jpg)
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill gray -annotate +29+69 'Anthony' \ -annotate +28+68 'Anthony' \ -annotate +27+67 'Anthony' \ -annotate +26+66 'Anthony' \ -annotate +25+65 'Anthony' \ -annotate +24+64 'Anthony' \ -fill navy -annotate +23+63 'Anthony' \ font_extrude.jpg |
![[IM Output]](font_extrude.jpg)
轮廓字体:我们可以使用多个绘制和小的位置偏移来创建轮廓字体。
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill black -annotate +24+64 'Anthony' \ -annotate +26+64 'Anthony' \ -annotate +26+66 'Anthony' \ -annotate +24+66 'Anthony' \ -fill white -annotate +25+65 'Anthony' \ font_outlined.jpg |
![[IM Output]](font_outlined.jpg)
-stroke
”设置来绘制字体的轮廓,因此存在更好的解决方案。(请参阅下面的 描边字体)。无论如何,这种用于生成轮廓的多次重绘对于预先准备好的剪贴画图像非常有用,例如您可以在互联网上找到的所有图像。对于其他图形库和程序(例如来自“PHP
”的“GD
”等)也很有用,在这些程序中,无法使用“-stroke
”设置。展示这种轮廓样式的另一个原因是,在描绘具有非常尖锐点的字体时,结果可能会更好。例如,这里我们绘制了 12 次字体以显示字体的尖锐点。这里的轮廓也绘制得稍厚一些。
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -draw "fill black text 27,67 'Anthony' \ text 25,68 'Anthony' \ text 23,67 'Anthony' \ text 22,65 'Anthony' \ text 23,63 'Anthony' \ text 25,62 'Anthony' \ text 27,63 'Anthony' \ text 28,65 'Anthony' \ fill white text 25,65 'Anthony' " \ font_outlined_12.jpg |
![[IM Output]](font_outlined_12.jpg)
-draw
”参数中更改绘图 -fill”颜色。 多色轮廓:此技术有用的另一个原因是,您不限于在绘制字体时只使用一种轮廓颜色。通过以非常精心设计的顺序用 5 种不同的颜色重新绘制 12 次字体,您可以制作出色彩鲜艳的“凸起”字体,并具有一些边缘颜色平滑效果。
magick -size 320x100 xc:lightblue \ -font Candice -pointsize 72 -gravity center \ -draw "fill navy text 2,2 'Anthony' \ fill navy text 0,3 'Anthony' \ fill navy text 3,0 'Anthony' \ fill dodgerblue text 0,2 'Anthony' \ fill dodgerblue text 2,0 'Anthony' \ fill dodgerblue text -2,2 'Anthony' \ fill dodgerblue text 2,-2 'Anthony' \ fill lavender text -2,-2 'Anthony' \ fill lavender text 0,-3 'Anthony' \ fill lavender text -3,0 'Anthony' \ fill skyblue text 0,-2 'Anthony' \ fill skyblue text -2,0 'Anthony' \ fill blue text 0,0 'Anthony' " \ font_colourful.jpg |
![[IM Output]](font_colourful.jpg)
-stroke
”设置允许您直接绘制字体的轮廓。通常,描边颜色设置为“无”,因此不使用。描边的厚度通过“-strokewidth
”来改变,默认为 1 的良好值。
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill white -stroke black -annotate +25+65 'Anthony' \ font_stroke.jpg |
![[IM Output]](font_stroke.jpg)
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill white -stroke black -strokewidth 3 \ -annotate +25+65 'Anthony' font_stroke_3.jpg |
![[IM Output]](font_stroke_3.jpg)
粗描边:再次重新绘制字体第二次,但没有打开描边,线条的内部部分会被移除,从而创建一个更令人愉悦的粗轮廓字体。
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 -fill white \ -stroke black -strokewidth 5 -annotate +25+65 'Anthony' \ -stroke none -annotate +25+65 'Anthony' \ font_stroke_thick.jpg |
![[IM Output]](font_stroke_thick.jpg)
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill none -stroke black -annotate +25+65 'Anthony' \ font_stroke_thin.jpg |
![[IM Output]](font_stroke_thin.jpg)
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill none -stroke black -strokewidth 3 -annotate +25+65 'Anthony' \ -fill none -stroke white -strokewidth 1 -annotate +25+65 'Anthony' \ font_stroke_double.jpg |
![[IM Output]](font_stroke_double.jpg)
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 -fill white \ -stroke black -strokewidth 25 -annotate +25+65 'Anthony' \ -stroke white -strokewidth 20 -annotate +25+65 'Anthony' \ -stroke black -strokewidth 15 -annotate +25+65 'Anthony' \ -stroke white -strokewidth 10 -annotate +25+65 'Anthony' \ -stroke black -strokewidth 5 -annotate +25+65 'Anthony' \ -stroke none -annotate +25+65 'Anthony' \ font_psychedelic.jpg |
![[IM Output]](font_psychedelic.jpg)
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill black -stroke black -strokewidth 5 -annotate +25+65 'Anthony' \ -fill white -stroke white -strokewidth 1 -annotate +25+65 'Anthony' \ font_balloon.jpg |
![[IM Output]](font_balloon.jpg)
连接字符:通过使用一个小负数的字符间距调整设置(添加 IM v6.4.7-10)并绘制两次字体(例如在前面的示例中),您可以使“粗体”字体中的所有字符连接在一起,从而产生有趣的变化。
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -kerning -6 -strokewidth 4 -fill white \ -stroke black -annotate +28+68 Anthony \ -stroke none -annotate +28+68 Anthony \ font_joined.jpg |
![[IM Output]](font_joined.jpg)
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -stroke black -strokewidth 4 -fill white \ -stroke black -annotate +28+68 A -stroke none -annotate +28+68 A \ -stroke black -annotate +90+68 n -stroke none -annotate +90+68 n \ -stroke black -annotate +120+68 t -stroke none -annotate +120+68 t \ -stroke black -annotate +138+68 h -stroke none -annotate +138+68 h \ -stroke black -annotate +168+68 o -stroke none -annotate +168+68 o \ -stroke black -annotate +193+68 n -stroke none -annotate +193+68 n \ -stroke black -annotate +223+68 y -stroke none -annotate +223+68 y \ font_overlapped.jpg |
![[IM Output]](font_overlapped.jpg)
-strokewidth
”设置。请参阅确定字体度量以获取示例。请注意,与使用“-kerning
”设置(前面的示例)不同,上面每个字符的位置都通过不同的量进行了艺术性调整,而不仅仅是某个简单的固定量。例如,“t”和“h”之间只有很少的重叠,但“n”和“y”字符之间则有更多的重叠。 抖动字符:如果您绘制单个字符(是否重叠)走得更远,则可以以“抖动”或随机模式放置它们,尤其是在不同的上下偏移的情况下。您甚至可以将其发挥到极致,以生成特殊效果,例如...
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -stroke black -strokewidth 4 -fill white \ -stroke black -annotate +26+80 A -stroke none -annotate +26+80 A \ -stroke black -annotate +95+63 n -stroke none -annotate +95+63 n \ -stroke black -annotate +133+54 t -stroke none -annotate +133+54 t \ -stroke black -annotate +156+67 h -stroke none -annotate +156+67 h \ -stroke black -annotate +193+59 o -stroke none -annotate +193+59 o \ -stroke black -annotate +225+59 n -stroke none -annotate +225+59 n \ -stroke black -annotate +266+54 y -stroke none -annotate +266+54 y \ font_jittered.jpg |
![[IM Output]](font_jittered.jpg)
模糊字体:“
-blur
”运算符对字体的颜色进行直接扩展。此运算符允许您获取图像并将其向各个方向扩展。这使您可以生成更柔和的阴影或喷漆效果。以下示例显示了您可以使用此运算符实现的效果。
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill navy -annotate +25+65 'Anthony' \ -blur 0x3 font_fuzzy.jpg |
![[IM Output]](font_fuzzy.jpg)
![]() ![]() |
“-blur ”(或“-gaussian ”)运算符修改的区域比您可能想象的要大得多。如果您的背景画布不够大,则可能会收到这些运算符的错误。如果发生这种情况,请向图像添加额外的空间,例如使用“-border ”,或限制运算符的工作半径(第一个参数)。
此外,图像的模糊通常会使随后使用“ |
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -annotate +30+70 'Anthony' -blur 0x4 \ -fill white -stroke black -annotate +25+65 'Anthony' \ font_shadow_fuzzy.jpg |
![[IM Output]](font_shadow_fuzzy.jpg)
-shadow
”运算符不仅允许您为包含透明度的图像生成和定位柔和的模糊阴影,还允许您设置使用任何颜色并设置常规透明度级别。
magick -size 300x100 xc:none -font Candice -pointsize 72 \ -fill white -stroke black -annotate +25+65 'Anthony' \ \( +clone -background navy -shadow 70x4+5+5 \) +swap \ -background lightblue -flatten -trim +repage font_shadow_soft.jpg |
![[IM Output]](font_shadow_soft.jpg)
-shadow
”运算符的更多信息,请参阅生成阴影。从 IM v6.3.1 开始,“montage
”命令还可以生成包含透明度的图像的柔和“形状”阴影。这意味着您可以非常轻松地为“label:
”图像添加阴影。
montage -background none -fill white -font Candice \ -pointsize 72 label:'Anthony' +set label \ -shadow -background lightblue -geometry +5+5 \ font_montage_shadow.jpg |
![[IM Output]](font_montage_shadow.jpg)
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -annotate +25+65 'Anthony' -blur 0x5 \ -fill white -annotate +25+65 'Anthony' font_outline_soft.jpg |
![[IM Output]](font_outline_soft.jpg)
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -stroke black -strokewidth 8 -annotate +25+65 'Anthony' -blur 0x8 \ -fill white -stroke none -annotate +25+65 'Anthony' \ font_denser_soft_outline.jpg |
![[IM Output]](font_denser_soft_outline.jpg)
距离模糊阴影:随着可变模糊映射的引入,您现在可以模糊阴影,使其随着阴影与投射物体的表观距离而变得更加模糊。例如,这里我使用了倾斜阴影字体并模糊了阴影,使其在顶部不模糊,在底部更模糊。
magick -size 320x40 xc:lightblue -font Candice -pointsize 72 \ -fill RoyalBlue -annotate 0x125+20+0 'Anthony' \ \( -size 320x45 gradient:black -append \) \ -compose Blur -set option:compose:args 20x5+45 -composite \ \( -size 320x60 xc:lightblue \ -fill Navy -annotate 0x0+20+59 'Anthony' \) \ +swap -append font_var_blur.jpg |
![[IM Output]](font_var_blur.jpg)
脏印刷字体:像素略微扩展,然后模糊,并进行了几次阈值处理以平滑最终轮廓。结果是看起来像在粗糙报纸上打印的字体。
magick -size 320x100 xc: \ -font Candice -pointsize 72 -annotate +25+65 'Anthony' \ -spread 1 -blur 0x1 -threshold 50% -blur 0x1 font_dirty_print.jpg |
![[IM Output]](font_dirty_print.jpg)
斜角字体:阴影运算符可用于生成外观非常漂亮的 3D 字体,其边缘呈斜角且平滑弯曲。
magick -size 320x100 xc:black -font Candice -pointsize 72 \ -fill white -annotate +25+65 'Anthony' \ -shade 140x45 font_beveled.jpg |
![[IM Output]](font_beveled.jpg)
锥形字体:通过使用新的形态距离方法(从 IM v6.6.2 开始)结合阴影运算符,您可以使整个字体看起来像一个三维山脊。这确实需要根据具有抗锯齿形状的距离对抗锯齿像素进行一些特殊处理,但结果是一个锥形山状字体。
magick -size 320x100 xc:black -font Candice -pointsize 72 \ -fill white -annotate +25+65 'Anthony' \ -gamma 2 +level 0,1000 -white-threshold 999 \ -morphology Distance Euclidean:4,1000 -auto-level \ -shade 135x30 -auto-level +level 10,90% font_conic.jpg |
![[IM Output]](font_conic.jpg)
-adaptive-blur
”,您可以使结果平滑,从而为生成的字体带来更好且奇怪的光泽外观。
magick -size 320x100 xc:black -font Candice -pointsize 72 \ -fill white -annotate +25+65 'Anthony' \ -gamma 2 +level 0,1000 -white-threshold 999 \ -morphology Distance Euclidean:4,1000 -auto-level \ -shade 135x30 -auto-level +level 10,90% \ -adaptive-blur 0x2 font_conic_smoothed.jpg |
![[IM Output]](font_conic_smoothed.jpg)
-adaptive-blur
”移动到使用阴影之前会导致边缘模糊,但不会模糊字体的中心脊(骨架)。结果看起来像锋利的脊正在推入橡胶片中。
magick -size 320x100 xc:black -font Candice -pointsize 72 \ -fill white -annotate +25+65 'Anthony' \ -gamma 2 +level 0,1000 -white-threshold 999 \ -morphology Distance Euclidean:4,1000 -auto-level \ -adaptive-blur 0x2 \ -shade 135x30 -auto-level +level 10,90% font_conic_ridge.jpg |
![[IM Output]](font_conic_ridge.jpg)
magick -size 320x100 xc:black -font ArialBk -pointsize 70 \ -fill white -annotate +5+70 'Anthony' \ -gamma 2 +level 0,1000 -white-threshold 999 \ -morphology Distance Chebyshev:1,1000 -auto-level \ -shade 135x30 -auto-level +level 10,90% font_chebyshev.jpg |
![[IM Output]](font_chebyshev.jpg)
magick -size 320x100 xc:black -font Candice -pointsize 72 \ -fill white -annotate +25+65 'Anthony' \ -gamma 2 +level 0,1000 -white-threshold 999 \ -morphology Distance Euclidean:4,1000 -level 0,5000 \ -shade 135x30 -auto-level +level 10,90% font_inner_bevel.jpg |
![[IM Output]](font_inner_bevel.jpg)
拱形字体:“
-wave
”运算符(有关详细信息,请参阅正弦波位移)将垂直移动图像的像素,以形成拱形。垂直线将保持垂直,字符将被剪切以产生曲线。
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill navy -annotate +25+65 'Anthony' \ -background lightblue -wave -50x640 -crop x110+0+10 \ font_wavy.jpg |
![[IM Output]](font_wavy.jpg)
-wave
”创建拱形,您需要使用“波长”是图像宽度两倍的值(2 × 320 或 640 像素)。此外,由于“-wave
”会根据其拱起的程度向图像添加额外的空间,因此需要在之后修剪或裁剪该空间。这是一种简单、快速但有效的制作文本拱形的方法。 弧形字体:通用变形运算符还提供其他文本/图像扭曲方法。“Arc
”方法例如会将字体弯曲成真正的圆弧,而不是前面示例中垂直移动的“拱形”。
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill navy -annotate +25+65 'Anthony' \ -distort Arc 120 -trim +repage \ -bordercolor lightblue -border 10 font_arc.jpg |
![[IM Output]](font_arc.jpg)
圆形字体:您甚至可以将其发挥到极致,并将文本包裹成一个完整的或几乎完整的圆形。
magick -font Candice -pointsize 32 -background lightblue \ -fill navy label:"Anthony's IM Examples" \ -virtual-pixel background -distort Arc 340 \ font_circle.jpg |
![[IM Output]](font_circle.jpg)
magick -font Candice -pointsize 32 -background lightblue \ -fill navy label:"Anthony's IM Examples" \ -rotate 12 -virtual-pixel background -distort Arc 360 \ -trim -bordercolor lightblue -border 5x5 font_spiral.jpg |
![[IM Output]](font_spiral.jpg)
颤音字体:我们在上面拱形字体中使用的“
-wave
”运算符也可以以更高的频率和更小的幅度使用来制作颤音字体。此外,通过添加一些旋转操作,您甚至可以使颤音以任何您喜欢的角度进行!
magick -size 320x100 xc:lightblue -font Candice -pointsize 72 \ -fill navy -annotate +25+65 'Anthony' \ -background lightblue -rotate 85 -wave 2x5 -rotate -85 \ -gravity center -crop 320x100+0+0 +repage font_vibrato.jpg |
![[IM Output]](font_vibrato.jpg)
-motion-blur
”允许您为图像中的对象创建类似彗星的尾巴。
magick -size 340x120 xc:lightblue -font Candice -pointsize 72 \ -fill navy -annotate +45+95 'Anthony' -motion-blur 0x25+65 \ -fill black -annotate +45+95 'Anthony' -motion-blur 0x1+65 \ font_comet.jpg |
![[IM Output]](font_comet.jpg)
magick -size 320x120 xc:lightblue -font Candice -pointsize 72 \ -fill black -annotate +25+95 'Anthony' -motion-blur 0x25+90 \ -background lightblue -rotate 60 -wave 3x35 -rotate -60 \ -gravity center -crop 320x120+0+0 +repage +gravity \ -fill navy -annotate +25+95 'Anthony' font_smoking.jpg |
![[IM Output]](font_smoking.jpg)
您是否有想添加到上述列表中的有趣转换?
使用蒙版图像与字体
在背景图像上绘制“印章字体”实际上比我上面详细介绍的大多数生成花哨字体的更复杂。原因是原始字体的一部分被擦除了,这在将其绘制在不是简单纯色的背景上时会出现问题。以下是我们上面生成的复合字体图像。
|
![[IM Output]](font_stamp.jpg)
magick -size 320x100 xc:transparent -font Candice -pointsize 72 \ -fill black -annotate +24+64 'Anthony' \ -fill white -annotate +26+66 'Anthony' \ -fill transparent -annotate +25+65 'Anthony' \ trans_stamp.png |
![[IM Output]](trans_stamp.png)
magick composite
”命令忽略中间部分。“magick composite
”蒙版图像是一个灰度图像,纯黑色表示将要透明的部分,纯白色表示您希望完全可见(不透明)的部分。任何灰色阴影都将绘制为半透明,与下面的背景颜色融合。好吧,我们上面的图像几乎是正确的,所以让我们只屏蔽掉我们不想要的所有部分。我们从黑色背景(完全透明)开始,然后用白色绘制任何我们想要的东西,用黑色绘制任何我们不想要的东西。
magick -size 320x100 xc:black -font Candice -pointsize 72 \ -fill white -annotate +24+64 'Anthony' \ -fill white -annotate +26+66 'Anthony' \ -fill black -annotate +25+65 'Anthony' \ mask_mask.jpg |
![[IM Output]](mask_mask.jpg)
|
![[IM Output]](mask_result.jpg)
magick -composite
”的三参数形式是……结果不错,但现在我们需要两张图像来绘制复合字体。如果我们只需要一张图像,并且蒙版直接构建到图像本身中,那会更好。基本上,我们希望用我们创建的字体图像蒙版的副本完全替换字体图像的 alpha 通道。也就是说,我们将字体图像(提供像素的颜色)直接与其蒙版(提供图像的 alpha 通道)合并。“CopyOpacity
”alpha 合成设置执行此替换。请注意命令中参数的顺序。在这种情况下,字体本身是背景图像,而蒙版是叠加到背景图像中的图像。
magick composite -compose CopyOpacity mask_mask.jpg trans_stamp.png \ trans_stamp3.png magick composite trans_stamp3.png plasma_background.jpg mask_result3.jpg |
![[IM Output]](trans_stamp3.png)
![[IM Output]](mask_result3.jpg)
![]() ![]() |
缩小像上面那样更大的透明字体印章会创建一个非常好的水印。缩小会使轮廓不那么不透明,也不那么突出,就像水印应该的那样。两种颜色还可以确保标记在非常浅和非常深的图像上都能可靠地显示。 |
高级字体处理
通过将上述技术结合起来,结合适当的颜色和其他可用的花哨字体,您可以制作一些奇妙的效果,这些效果通常看起来与上面显示的原始技术完全不同。更复杂的字体 - 一个示例
例如,这里我们生成了一段非常复杂且多彩的文本。
magick -font Times-Bold -pointsize 64 \ -background none label:"Colorful Arc" \ \( +clone -sparse-color Barycentric '0,%h blue %w,0 red' \ \) -compose In -composite \ -virtual-pixel transparent -distort arc 120 \ \( +clone -background black -shadow 100x2+4+4 \ \) +swap -background white -compose over -layers merge +repage \ colorful_arc.jpg |
![[IM Output]](colorful_arc.jpg)
霓虹灯标志
这是一个简单的示例。通过在深色背景上使用柔和轮廓字体,但使用所有相同的颜色和适当的字体,您可以生成一个简单的“霓虹灯标志”效果……
magick -fill dodgerblue -background black -font Anaconda -pointsize 72 \ label:' I M Examples ' -bordercolor black -border 30x30 \ \( +clone -blur 0x25 -level 0%,50% \) \ -compose screen -composite neon_sign.gif |
![[IM Output]](neon_sign.gif)
金属效果
此效果本质上是圆形和颜色查找表替换效果。请参阅讨论金属效果。snibgo提供的示例
# Generate a blured input font shaped mask # first blur-level is a rounding or 'puddling' effect # the second blur is the important one for the metallic effect. magick -background none -pointsize 160 -font Candice label:" Anthony " \ -blur 0x5 -channel A -level 40%,60% +channel \ -blur 0x3 metallic_input.png # Metallic Color Lookup Table magick \ -size 1x1000 gradient: -gamma 0.9 \ -function Sinusoid 2.25,0,0.5,0.5 \ \( gradient:'rgb(100%,100%,80%)-black' -gamma 1 \) \ +swap \ -compose Overlay -composite \ -rotate 90 \ metallic_clut.png # Give blurred font a metallic look # * first create a vertial gradient # * then merge this with a 'shade' reflective gradient # * before applying the color to the resulting gradient # * finally add a shadow. magick metallic_input.png -set colorspace RGB \ \( -clone 0 -alpha off \ -sparse-color Barycentric "0,0 White 0,%[fx:h-1] Black" \ -alpha on \ \) \ \( -clone 0 -alpha extract -shade 135x45 -auto-gamma -auto-level \ -alpha on -channel A -level 0%x10% +channel \ \) \ -delete 0 -compose Overlay -composite \ metallic_clut.png -clut -set colorspace sRGB \ \ \( +clone -background navy -shadow 80x2+5+5 \ \) +swap -background None -compose Over -layers merge \ \ -trim +repage metallic.png |
![[IM Output]](metallic.png)