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
」設定會覆寫「-draw
」運算子的任何「-fill
」顏色。![]() ![]() |
從 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
」參數內更改。多色描邊:此技術有用的另一個原因是您在繪製字體時不限於一種描邊顏色。透過以精心設計的順序以 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)
-strokewitdh
」設定的情況下產生每個字元的標籤來確定。有關示例,請參見 確定字型指標。請注意,與使用「-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
」命令還可以產生包含透明度的圖像的柔和「形狀」陰影。這意味著您可以非常輕鬆地對「標籤:
」圖像進行陰影處理。
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)
斜角字體:陰影運算子可用於產生具有斜角和平滑彎曲邊緣的精美三維字體。
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 通道)合併。Alpha 合成設置「CopyOpacity
」執行此替換。請注意命令中參數的順序。在這種情況下,字體本身是背景圖像,而遮罩是被疊加到背景圖像中的圖像。
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)