⚠️ これは 非公式の翻訳サイトです。ImageMagick Studio LLC とは無関係です。正確な情報は 原文(https://usage.imagemagick.org/backgrounds/index.html) を参照してください。

ImageMagick 使用例 -- 背景

ImageMagick 使用例 前書きと索引 これは、いくつかの『ランダムな』キャンバスに対してさまざまな変換を適用した一覧表で、単一の大きな画像であれ、Web ページ用の背景タイルであれ、お望みのサイズで興味深いランダムな背景を生成する手法を示しています。表は、ここに示すほかのすべての画像を生成するために使われた、最初の『ランダムな』画像を生成する方法から始まります。あとはさまざまな画像の『変換』をコマンドへ挿入するだけで、生の画像を、ここに示すものに似た何かへ magick で変換できます。そこから各種設定を自分で調整して、まさに望みのタイプの背景画像を生成できます。自分の例を作ろうとする前に、末尾の注意書きを必ず読んでください。そして見つけた興味深いバリエーションがあれば、ぜひメールでお知らせください。 入力画像 :- ジェネレータ、変換、後処理 |
---|---
ここに示す画像結果は "-noop" のヌル変換演算子で生成されています
プラズマフラクタル (非タイル化キャンバス画像)
|

  magick -size 120x120  plasma:fractal fractal.png
  magick fractal.png   _{..transform..}_ \
           -shave 20x20 +repage  -auto_level  _{result}_

[IM Output]
ランダムノイズ (タイル化可能な背景画像)
|

  magick -size 80x80 xc: +noise Random noise.png
  magick noise.png -virtual-pixel tile  _{..transform..}_ \
          -auto_level  _{result}_

| [IM Output]
ランダム六角タイル (六角タイル背景画像)
|

  magick -size 50x80 xc: +noise Random -write mpr:rand \
           -extent 100x80   -page +50-40 mpr:rand \
           -page +50+40 mpr:rand -flatten  hextile.png
  magick hextile.png -virtual-pixel tile  _{..transform..}_ \
          -auto_level    _{result}_

| | [IM Output]
|
基本的な変換
blur_raw (後段の -auto-level なし) |

  -blur 0x1

[Fractal] | [Noise] | [Noise]
blur_1 |

  -blur 0x1

[Fractal] | [Noise] | [Noise]
blur_3 |

  -blur 0x3

[Fractal] | [Noise] | [Noise]
blur_5 |

  -blur 0x5

[Fractal] | [Noise] | [Noise]
blur_10 |

  -blur 0x10

[Fractal] | [Noise] | [Noise]
intensity |

  -blur 0x10  -colorspace Gray

[Fractal] | [Noise] | [Noise]
channel |

  -blur 0x10  -fx G

[Fractal] | [Noise] | [Noise]
hues |

  -blur 0x10 -auto-level -separate -background white \
     -compose ModulusAdd -flatten -channel R -combine +channel \
     -set colorspace HSB -colorspace RGB

[Fractal] | [Noise] | [Noise]
シェード変換
shade_raw (後段の -auto-level なし) |

  -shade 120x45

[Fractal] | [Noise] | [Noise]
shade |

  -shade 120x45

[Fractal] | [Noise] | [Noise]
shade_dimmed (後段の -auto-level なし) |

  -shade 120x45 -auto-level -fill grey -colorize 40%

[Fractal] | [Noise] | [Noise]
shade_1 |

  -blur 0x1 -shade 120x45

[Fractal] | [Noise] | [Noise]
shade_2 |

  -blur 0x2 -shade 120x45

[Fractal] | [Noise] | [Noise]
shade_5 |

  -blur 0x5 -shade 120x45

[Fractal] | [Noise] | [Noise]
shade_10 |

  -blur 0x10 -fx G -shade 120x45

[Fractal] | [Noise] | [Noise]
エンボス変換
emboss_1 |

  -blur 0x5  -emboss 1

[Fractal] | [Noise] | [Noise]
emboss_1g |

  -blur 0x5  -emboss 1  -fx G

[Fractal] | [Noise] | [Noise]
emboss_0s |

  -blur 0x3  -emboss .5 -shade 120x45

[Fractal] | [Noise] | [Noise]
emboss_1s |

  -blur 0x5  -emboss 1  -shade 120x45

[Fractal] | [Noise] | [Noise]
emboss_1gs |

  -blur 0x5  -emboss 1  -fx G  -shade 120x45

[Fractal] | [Noise] | [Noise]
emboss_5gs |

  -blur 0x10 -emboss 5  -fx G  -shade 120x45

[Fractal] | [Noise] | [Noise]
エッジ変換
charcoal |

  -blur 0x2  -charcoal 10 -negate

[Fractal] | [Noise] | [Noise]
charcoal_10s |

  -blur 0x2  -charcoal 10 -negate -shade 120x45

[Fractal] | [Noise] | [Noise]
charcoal_1s |

  -blur 0x2  -charcoal 1  -negate -shade 120x45

[Fractal] | [Noise] | [Noise]
edges |

  -blur 0x2  -edge 10

[Fractal] | [Noise] | [Noise]
edge_grey |

  -blur 0x2  -edge 10 -fx G

[Fractal] | [Noise] | [Noise]
mesas |

  -blur 0x2  -edge 10 -fx G -shade 120x45

[Fractal] | [Noise] | [Noise]
線を生成する変換
lines |

  -blur 0x10 -emboss 4 -edge 1

[Fractal] | [Noise] | [Noise]
loops |

  -blur 0x10 -edge 15  -edge 1  -blur 0x1

[Fractal] | [Noise] | [Noise]
engrave_loops |

  -blur 0x10 -edge 15  -edge 1  -blur 0x1 -fx R+B+G -shade 280x45

[Fractal] | [Noise] | [Noise]
engrave_loop |

  -blur 0x10 -edge 15  -edge 1  -blur 0x1 -fx G -shade 280x45

[Fractal] | [Noise] | [Noise]
color_contours |

  -blur 0x10 -normalize -fx 'sin(u*4*pi)*100' -edge 1 -blur 0x1

[Fractal] | [Noise] | [Noise]
contours |

  -blur 0x10 -normalize -fx 'sin(g*4*pi)*100' \
     -edge 1 -blur 0x1 -shade 280x45

[Fractal] | [Noise] | [Noise]
複雑なテクスチャ付きブロブ変換
(奇妙な '-edge 1' 効果を使用)
blobs |

  -blur 0x10 -edge 1

[Fractal] | [Noise] | [Noise]
blobs_grey |

  -blur 0x10 -edge 1 -fx '(R+G+B)/3'

[Fractal] | [Noise] | [Noise]
pits |

  -blur 0x10 -edge 1 -fx G -shade 280x45

[Fractal] | [Noise] | [Noise]
ridges |

  -blur 0x10 \( +clone -negate \) -edge 1 -fx u.G+v.G -shade 280x45

[Fractal] | [Noise] | [Noise]
mottled |

  -blur 0x10 -write mpr:save -negate -edge 1 -negate -fx G \
     \( mpr:save -edge 1 -fx G \) -shade 280x45 -evaluate-sequence mean

[Fractal] | [Noise] | [Noise]
ペイント変換
paint_raw10 (後段の -auto-level なし) |

  -paint 10

[Fractal] | [Noise] | [Noise]
paint_areas |

  -paint 10  -blur 0x5  -paint 10

[Fractal] | [Noise] | [Noise]
paint_raw10s |

  -paint 10  -shade 120x45

[Fractal] | [Noise] | [Noise]
paint_8 |

  -blur 0x5  -paint 8

[Fractal] | [Noise] | [Noise]
paint_8s |

  -blur 0x5  -paint 8  -shade 120x45

[Fractal] | [Noise] | [Noise]
paint_3 |

  -blur 0x10 -paint 3

[Fractal] | [Noise] | [Noise]
paint_3s |

  -blur 0x10 -paint 3  -shade 120x45

[Fractal] | [Noise] | [Noise]
paint_3d |

  -blur 0x10 -paint 3 \( +clone -shade 120x45 \) \
     +swap  -compose overlay -composite

[Fractal] | [Noise] | [Noise]
グラデーション変換
levels (後段の -auto-level なし) |

  -blur 0x12 -fx intensity -normalize \
     -size 1x9 gradient:navy-lavender \
     -interpolate integer -fx 'v.p{0,G*(v.h-1)}'

[Fractal] | [Noise] | [Noise]
levels_3d (後段の -auto-level なし) |

  -blur 0x12 -fx intensity -normalize \
     -size 1x9 gradient:navy-lavender \
     -interpolate integer -fx 'v.p{0,G*(v.h-1)}' \
     \( +clone -shade 120x45 -normalize \) \
     -compose overlay -composite

[Fractal] | [Noise] | [Noise]
zebra |

  -blur 0x12 -normalize \
     -size 1x19   pattern:gray50   -fx 'v.p{0,G*(v.h-1)}'

[Fractal] | [Noise] | [Noise]
midlevel |

  -blur 0x12 -normalize \
     \( -size 1x9 xc: -draw 'color 0,4 point' -negate \) \
     -fx 'v.p{0,G*(v.h-1)}'

[Fractal] | [Noise] | [Noise]
edged_level (後段の -auto-level なし) |

  -blur 0x12 -normalize \
     \( -size 1x9 xc: -draw 'color 0,4 point' \) \
     -fx '(.6+.2*v.p{0,G*(v.h-1)})' \
     \( +clone -normalize -edge 1 \)  -fx 'u+v'

[Fractal] | [Noise] | [Noise]
layered_levels (後段の -auto-level なし) |

  -blur 0x12 -normalize \
     \( -size 1x9 xc: -draw 'color 0,4 point' \) \
     -fx '(.5+.3*v.p{0,u*(v.h-1)})' \
     \( +clone -normalize -edge .3 -fx 'R+G+B' \) \
     -fx 'intensity+v'  -fill skyblue -tint 100

[Fractal] | [Noise] | [Noise]
その他
filaments |

  -blur 0x5 -normalize -fx g \
     -sigmoidal-contrast 15x50% -solarize 50%

[Fractal] | [Noise] | [Noise]

良い背景ジェネレータや画像変換を持っている、あるいは思いついた場合は、ここに追加してほかの人と共有できるよう、ぜひお知らせください。

最後の重要な注意

2つのランダムノイズ画像は、非常に『ランダム』であるためタイル化可能で、変換の途中でもタイル化可能な状態を保つために "[-virtual-pixels](https://imagemagick.org/command-line-options/#virtual-pixels)" を使用しています。しかしプラズマ画像はそもそもタイル化可能ではないため、拡大した版を用い、あとで縁を "[-shave](https://imagemagick.org/command-line-options/#shave)" で削ぎ落として、多くの操作で生じる望ましくない縁の影響を取り除いています。これらの手法についてはタイル画像の変更でさらに詳しく解説しています。なお、最後の "[-auto_level](https://imagemagick.org/command-line-options/#normalize)" は、結果のコントラストを高めるためにほとんどの画像へ適用していますが、変換から生じた着色や陰影を保つために不要と明記された変換の場合は除きます。"[-blur](https://imagemagick.org/command-line-options/#blur)"、"[-emboss](https://imagemagick.org/command-line-options/#emboss)"、"[-edge](https://imagemagick.org/command-line-options/#edge)" などの多くの画像変換はグレースケール変換であるため、3つの色チャンネルに対して互いに完全に独立して作用します。その結果、多くの画像で、3つの別々の画像が重ね合わされて陰影が付けられたように見えます。最後の例 "layered_levels" は、3つのレベルそれぞれに対して同時に作用しつつも、それらを別々に保ち、最終ステップで足し合わせて色付けするように設計されています。この三重効果は、最初にグレースケール化操作を適用するか、終了時に1つのチャンネルだけを抽出することで取り除けます。私はたいてい 'green' すなわち 'G' チャンネルを抽出します。これはグレースケール画像において通常もっとも強いチャンネルだからですが、3つのうちどのチャンネルを使ってもかまいません。