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
" 設定を設定することでフォントの輪郭を描画できるため、はるかに優れたソリューションが存在します。(以下のストロークフォントを参照)。それにもかかわらず、輪郭を生成するためのこのような複数の再描画は、インターネット中に存在するような事前に準備されたクリップアート画像で非常に役立ちます。「GD
」からの「PHP
」など) "-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)
-fill
" 色は "-draw
" 引数の内部で変更できることに注意してください。 多色輪郭:この手法が有用であるもう一つの理由は、フォントを描画する際に1つの輪郭色に限定されないことです。フォントを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)
太いストローク:もう一度フォントを2回再描画しますが、ストロークをオフにすると、線の内部部分が削除され、より美しく太い輪郭のフォントが作成されます。
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 の追加)を使用し、フォントを2回描画する(前の例のように)と、「太い」フォントのすべての文字を連結して、興味深い変化を生み出すことができます。
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以降の新しい形態距離法とシェード演算子を組み合わせることで、フォント全体を3次元の山脈のように見せることができます。これは、アンチエイリアスされたシェイプを使用した距離に従ってアンチエイリアシングピクセルを特別な方法で処理する必要がありますが、その結果、円錐形の山のようなフォントになります。
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倍(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 -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
」形式は…です。良好な結果ですが、複合フォントを描画するには2つの画像が必要になりました。マスクが画像自体に直接組み込まれた1つの画像のみが必要な方が良いでしょう。基本的に、フォント画像のアルファチャネルを、作成したフォント画像マスクのコピーで完全に置き換えたいと考えています。つまり、フォント画像(ピクセルの色を提供)とそのマスク(画像のアルファチャネルを提供)を直接マージします。アルファ合成設定「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)
![]() ![]() |
上記のような大きな透明なフォントスタンプを縮小すると、非常に優れた透かしが作成されます。縮小すると、輪郭は不透明度が低くなり、目立たなくなります。透かしであるべきようにです。2つの色も、マークが非常に明るい画像と非常に暗い画像の両方で確実に表示されるようにします。 |
高度なフォント処理
上記のテクニックを組み合わせ、適切な色と利用可能な他のファッシーフォントを使用することで、素晴らしい効果を生み出すことができます。これらは、上記で示した元のテクニックとはまったく異なるように見えることがよくあります。より複雑なフォント - 例
たとえば、ここでは非常に複雑でカラフルなテキストを生成します。
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)