ImageMagick 使用例 -- 背景
ImageMagick 使用例 前書きと索引
これは、いくつかの『ランダムな』キャンバスに対してさまざまな変換を適用した一覧表で、単一の大きな画像であれ、Web ページ用の背景タイルであれ、お望みのサイズで興味深いランダムな背景を生成する手法を示しています。表は、ここに示すほかのすべての画像を生成するために使われた、最初の『ランダムな』画像を生成する方法から始まります。あとはさまざまな画像の『変換』をコマンドへ挿入するだけで、生の画像を、ここに示すものに似た何かへ magick で変換できます。そこから各種設定を自分で調整して、まさに望みのタイプの背景画像を生成できます。自分の例を作ろうとする前に、末尾の注意書きを必ず読んでください。そして見つけた興味深いバリエーションがあれば、ぜひメールでお知らせください。 入力画像 :- ジェネレータ、変換、後処理 |
---|---
ここに示す画像結果は "-noop" のヌル変換演算子で生成されています
プラズマフラクタル (非タイル化キャンバス画像)
|
magick -size 120x120 plasma:fractal fractal.png
magick fractal.png _{..transform..}_ \
-shave 20x20 +repage -auto_level _{result}_
magick -size 80x80 xc: +noise Random noise.png
magick noise.png -virtual-pixel tile _{..transform..}_ \
-auto_level _{result}_
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]](../static/img/backgrounds/hextile_noop.png)
|
基本的な変換
blur_raw (後段の -auto-level なし) |
-blur 0x1
-blur 0x1
-blur 0x3
-blur 0x5
-blur 0x10
-blur 0x10 -colorspace Gray
-blur 0x10 -fx G
-blur 0x10 -auto-level -separate -background white \
-compose ModulusAdd -flatten -channel R -combine +channel \
-set colorspace HSB -colorspace RGB
|
| ![[Noise]](../static/img/backgrounds/hextile_hues.png)
シェード変換
shade_raw (後段の -auto-level なし) |
-shade 120x45
-shade 120x45
|
| ![[Noise]](../static/img/backgrounds/hextile_shade.png)
shade_dimmed (後段の -auto-level なし) |
-shade 120x45 -auto-level -fill grey -colorize 40%
-blur 0x1 -shade 120x45
-blur 0x2 -shade 120x45
-blur 0x5 -shade 120x45
-blur 0x10 -fx G -shade 120x45
-blur 0x5 -emboss 1
-blur 0x5 -emboss 1 -fx G
-blur 0x3 -emboss .5 -shade 120x45
-blur 0x5 -emboss 1 -shade 120x45
-blur 0x5 -emboss 1 -fx G -shade 120x45
-blur 0x10 -emboss 5 -fx G -shade 120x45
-blur 0x2 -charcoal 10 -negate
-blur 0x2 -charcoal 10 -negate -shade 120x45
-blur 0x2 -charcoal 1 -negate -shade 120x45
-blur 0x2 -edge 10
-blur 0x2 -edge 10 -fx G
-blur 0x2 -edge 10 -fx G -shade 120x45
-blur 0x10 -emboss 4 -edge 1
-blur 0x10 -edge 15 -edge 1 -blur 0x1
-blur 0x10 -edge 15 -edge 1 -blur 0x1 -fx R+B+G -shade 280x45
-blur 0x10 -edge 15 -edge 1 -blur 0x1 -fx G -shade 280x45
-blur 0x10 -normalize -fx 'sin(u*4*pi)*100' -edge 1 -blur 0x1
-blur 0x10 -normalize -fx 'sin(g*4*pi)*100' \
-edge 1 -blur 0x1 -shade 280x45
|
| ![[Noise]](../static/img/backgrounds/hextile_contours.png)
複雑なテクスチャ付きブロブ変換
(奇妙な '-edge 1' 効果を使用)
blobs |
-blur 0x10 -edge 1
-blur 0x10 -edge 1 -fx '(R+G+B)/3'
-blur 0x10 -edge 1 -fx G -shade 280x45
-blur 0x10 \( +clone -negate \) -edge 1 -fx u.G+v.G -shade 280x45
-blur 0x10 -write mpr:save -negate -edge 1 -negate -fx G \
\( mpr:save -edge 1 -fx G \) -shade 280x45 -evaluate-sequence mean
|
| ![[Noise]](../static/img/backgrounds/hextile_mottled.png)
ペイント変換
paint_raw10 (後段の -auto-level なし) |
-paint 10
-paint 10 -blur 0x5 -paint 10
-paint 10 -shade 120x45
-blur 0x5 -paint 8
-blur 0x5 -paint 8 -shade 120x45
-blur 0x10 -paint 3
-blur 0x10 -paint 3 -shade 120x45
-blur 0x10 -paint 3 \( +clone -shade 120x45 \) \
+swap -compose overlay -composite
|
| ![[Noise]](../static/img/backgrounds/hextile_paint_3d.png)
グラデーション変換
levels (後段の -auto-level なし) |
-blur 0x12 -fx intensity -normalize \
-size 1x9 gradient:navy-lavender \
-interpolate integer -fx 'v.p{0,G*(v.h-1)}'
|
| ![[Noise]](../static/img/backgrounds/hextile_levels.png)
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
-blur 0x12 -normalize \
-size 1x19 pattern:gray50 -fx 'v.p{0,G*(v.h-1)}'
-blur 0x12 -normalize \
\( -size 1x9 xc: -draw 'color 0,4 point' -negate \) \
-fx 'v.p{0,G*(v.h-1)}'
|
| ![[Noise]](../static/img/backgrounds/hextile_midlevel.png)
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'
|
| ![[Noise]](../static/img/backgrounds/hextile_edged_level.png)
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
-blur 0x5 -normalize -fx g \
-sigmoidal-contrast 15x50% -solarize 50%
良い背景ジェネレータや画像変換を持っている、あるいは思いついた場合は、ここに追加してほかの人と共有できるよう、ぜひお知らせください。
最後の重要な注意
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つのうちどのチャンネルを使ってもかまいません。
![[IM Output]](../static/img/backgrounds/fractal_noop.png)
![[IM Output]](../static/img/backgrounds/noise_noop.png)
![[Fractal]](../static/img/backgrounds/fractal_blur_raw.png)
![[Noise]](../static/img/backgrounds/noise_blur_raw.png)
![[Noise]](../static/img/backgrounds/hextile_blur_raw.png)
![[Fractal]](../static/img/backgrounds/fractal_blur_1.png)
![[Noise]](../static/img/backgrounds/noise_blur_1.png)
![[Noise]](../static/img/backgrounds/hextile_blur_1.png)
![[Fractal]](../static/img/backgrounds/fractal_blur_3.png)
![[Noise]](../static/img/backgrounds/noise_blur_3.png)
![[Noise]](../static/img/backgrounds/hextile_blur_3.png)
![[Fractal]](../static/img/backgrounds/fractal_blur_5.png)
![[Noise]](../static/img/backgrounds/noise_blur_5.png)
![[Noise]](../static/img/backgrounds/hextile_blur_5.png)
![[Fractal]](../static/img/backgrounds/fractal_blur_10.png)
![[Noise]](../static/img/backgrounds/noise_blur_10.png)
![[Noise]](../static/img/backgrounds/hextile_blur_10.png)
![[Fractal]](../static/img/backgrounds/fractal_intensity.png)
![[Noise]](../static/img/backgrounds/noise_intensity.png)
![[Noise]](../static/img/backgrounds/hextile_intensity.png)
![[Fractal]](../static/img/backgrounds/fractal_channel.png)
![[Noise]](../static/img/backgrounds/noise_channel.png)
![[Noise]](../static/img/backgrounds/hextile_channel.png)
![[Fractal]](../static/img/backgrounds/fractal_shade_raw.png)
![[Noise]](../static/img/backgrounds/noise_shade_raw.png)
![[Noise]](../static/img/backgrounds/hextile_shade_raw.png)
![[Fractal]](../static/img/backgrounds/fractal_shade_dimmed.png)
![[Noise]](../static/img/backgrounds/noise_shade_dimmed.png)
![[Noise]](../static/img/backgrounds/hextile_shade_dimmed.png)
![[Fractal]](../static/img/backgrounds/fractal_shade_1.png)
![[Noise]](../static/img/backgrounds/noise_shade_1.png)
![[Noise]](../static/img/backgrounds/hextile_shade_1.png)
![[Fractal]](../static/img/backgrounds/fractal_shade_2.png)
![[Noise]](../static/img/backgrounds/noise_shade_2.png)
![[Noise]](../static/img/backgrounds/hextile_shade_2.png)
![[Fractal]](../static/img/backgrounds/fractal_shade_5.png)
![[Noise]](../static/img/backgrounds/noise_shade_5.png)
![[Noise]](../static/img/backgrounds/hextile_shade_5.png)
![[Fractal]](../static/img/backgrounds/fractal_shade_10.png)
![[Noise]](../static/img/backgrounds/noise_shade_10.png)
![[Noise]](../static/img/backgrounds/hextile_shade_10.png)
![[Fractal]](../static/img/backgrounds/fractal_emboss_1.png)
![[Noise]](../static/img/backgrounds/noise_emboss_1.png)
![[Noise]](../static/img/backgrounds/hextile_emboss_1.png)
![[Fractal]](../static/img/backgrounds/fractal_emboss_1g.png)
![[Noise]](../static/img/backgrounds/noise_emboss_1g.png)
![[Noise]](../static/img/backgrounds/hextile_emboss_1g.png)
![[Fractal]](../static/img/backgrounds/fractal_emboss_0s.png)
![[Noise]](../static/img/backgrounds/noise_emboss_0s.png)
![[Noise]](../static/img/backgrounds/hextile_emboss_0s.png)
![[Fractal]](../static/img/backgrounds/fractal_emboss_1s.png)
![[Noise]](../static/img/backgrounds/noise_emboss_1s.png)
![[Noise]](../static/img/backgrounds/hextile_emboss_1s.png)
![[Fractal]](../static/img/backgrounds/fractal_emboss_1gs.png)
![[Noise]](../static/img/backgrounds/noise_emboss_1gs.png)
![[Noise]](../static/img/backgrounds/hextile_emboss_1gs.png)
![[Fractal]](../static/img/backgrounds/fractal_emboss_5gs.png)
![[Noise]](../static/img/backgrounds/noise_emboss_5gs.png)
![[Noise]](../static/img/backgrounds/hextile_emboss_5gs.png)
![[Fractal]](../static/img/backgrounds/fractal_charcoal.png)
![[Noise]](../static/img/backgrounds/noise_charcoal.png)
![[Noise]](../static/img/backgrounds/hextile_charcoal.png)
![[Fractal]](../static/img/backgrounds/fractal_charcoal_10s.png)
![[Noise]](../static/img/backgrounds/noise_charcoal_10s.png)
![[Noise]](../static/img/backgrounds/hextile_charcoal_10s.png)
![[Fractal]](../static/img/backgrounds/fractal_charcoal_1s.png)
![[Noise]](../static/img/backgrounds/noise_charcoal_1s.png)
![[Noise]](../static/img/backgrounds/hextile_charcoal_1s.png)
![[Fractal]](../static/img/backgrounds/fractal_edges.png)
![[Noise]](../static/img/backgrounds/noise_edges.png)
![[Noise]](../static/img/backgrounds/hextile_edges.png)
![[Fractal]](../static/img/backgrounds/fractal_edge_grey.png)
![[Noise]](../static/img/backgrounds/noise_edge_grey.png)
![[Noise]](../static/img/backgrounds/hextile_edge_grey.png)
![[Fractal]](../static/img/backgrounds/fractal_mesas.png)
![[Noise]](../static/img/backgrounds/noise_mesas.png)
![[Noise]](../static/img/backgrounds/hextile_mesas.png)
![[Fractal]](../static/img/backgrounds/fractal_lines.png)
![[Noise]](../static/img/backgrounds/noise_lines.png)
![[Noise]](../static/img/backgrounds/hextile_lines.png)
![[Fractal]](../static/img/backgrounds/fractal_loops.png)
![[Noise]](../static/img/backgrounds/noise_loops.png)
![[Noise]](../static/img/backgrounds/hextile_loops.png)
![[Fractal]](../static/img/backgrounds/fractal_engrave_loops.png)
![[Noise]](../static/img/backgrounds/noise_engrave_loops.png)
![[Noise]](../static/img/backgrounds/hextile_engrave_loops.png)
![[Fractal]](../static/img/backgrounds/fractal_engrave_loop.png)
![[Noise]](../static/img/backgrounds/noise_engrave_loop.png)
![[Noise]](../static/img/backgrounds/hextile_engrave_loop.png)
![[Fractal]](../static/img/backgrounds/fractal_color_contours.png)
![[Noise]](../static/img/backgrounds/noise_color_contours.png)
![[Noise]](../static/img/backgrounds/hextile_color_contours.png)
![[Fractal]](../static/img/backgrounds/fractal_blobs.png)
![[Noise]](../static/img/backgrounds/noise_blobs.png)
![[Noise]](../static/img/backgrounds/hextile_blobs.png)
![[Fractal]](../static/img/backgrounds/fractal_blobs_grey.png)
![[Noise]](../static/img/backgrounds/noise_blobs_grey.png)
![[Noise]](../static/img/backgrounds/hextile_blobs_grey.png)
![[Fractal]](../static/img/backgrounds/fractal_pits.png)
![[Noise]](../static/img/backgrounds/noise_pits.png)
![[Noise]](../static/img/backgrounds/hextile_pits.png)
![[Fractal]](../static/img/backgrounds/fractal_ridges.png)
![[Noise]](../static/img/backgrounds/noise_ridges.png)
![[Noise]](../static/img/backgrounds/hextile_ridges.png)
![[Fractal]](../static/img/backgrounds/fractal_paint_raw10.png)
![[Noise]](../static/img/backgrounds/noise_paint_raw10.png)
![[Noise]](../static/img/backgrounds/hextile_paint_raw10.png)
![[Fractal]](../static/img/backgrounds/fractal_paint_areas.png)
![[Noise]](../static/img/backgrounds/noise_paint_areas.png)
![[Noise]](../static/img/backgrounds/hextile_paint_areas.png)
![[Fractal]](../static/img/backgrounds/fractal_paint_raw10s.png)
![[Noise]](../static/img/backgrounds/noise_paint_raw10s.png)
![[Noise]](../static/img/backgrounds/hextile_paint_raw10s.png)
![[Fractal]](../static/img/backgrounds/fractal_paint_8.png)
![[Noise]](../static/img/backgrounds/noise_paint_8.png)
![[Noise]](../static/img/backgrounds/hextile_paint_8.png)
![[Fractal]](../static/img/backgrounds/fractal_paint_8s.png)
![[Noise]](../static/img/backgrounds/noise_paint_8s.png)
![[Noise]](../static/img/backgrounds/hextile_paint_8s.png)
![[Fractal]](../static/img/backgrounds/fractal_paint_3.png)
![[Noise]](../static/img/backgrounds/noise_paint_3.png)
![[Noise]](../static/img/backgrounds/hextile_paint_3.png)
![[Fractal]](../static/img/backgrounds/fractal_paint_3s.png)
![[Noise]](../static/img/backgrounds/noise_paint_3s.png)
![[Noise]](../static/img/backgrounds/hextile_paint_3s.png)
![[Fractal]](../static/img/backgrounds/fractal_levels_3d.png)
![[Noise]](../static/img/backgrounds/noise_levels_3d.png)
![[Noise]](../static/img/backgrounds/hextile_levels_3d.png)
![[Fractal]](../static/img/backgrounds/fractal_zebra.png)
![[Noise]](../static/img/backgrounds/noise_zebra.png)
![[Noise]](../static/img/backgrounds/hextile_zebra.png)
![[Fractal]](../static/img/backgrounds/fractal_layered_levels.png)
![[Noise]](../static/img/backgrounds/noise_layered_levels.png)
![[Noise]](../static/img/backgrounds/hextile_layered_levels.png)
![[Fractal]](../static/img/backgrounds/fractal_filaments.png)
![[Noise]](../static/img/backgrounds/noise_filaments.png)
![[Noise]](../static/img/backgrounds/hextile_filaments.png)