ImageMagick 範例 --
背景範例

ImageMagick 範例前言與索引
這是一個表格,顯示如何對一些「隨機」畫布應用各種轉換,展示了如何產生您想要的任何尺寸的有趣隨機背景,無論是單個大圖像,還是網頁的背景圖塊。表格首先介紹了用於生成初始「隨機」圖像的方法,該圖像用於生成顯示的所有其他圖像。只需將各種圖像「轉換」插入命令中,即可將原始圖像轉換為類似於顯示的圖像。然後,您可以自行調整各種設定,以精確生成您想要的背景圖像類型。在嘗試創建自己的範例之前,請務必閱讀結尾處的註釋。並請將您可能遇到的任何有趣的變化發送給我。
輸入圖像:- 生成器、轉換和後處理  
此處顯示的圖像結果是使用「-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 0x1
[Fractal] [Noise] [Noise]
模糊_1
  -blur 0x1
[Fractal] [Noise] [Noise]
模糊_3
  -blur 0x3
[Fractal] [Noise] [Noise]
模糊_5
  -blur 0x5
[Fractal] [Noise] [Noise]
模糊_10
  -blur 0x10
[Fractal] [Noise] [Noise]
強度
  -blur 0x10  -colorspace Gray
[Fractal] [Noise] [Noise]
通道
  -blur 0x10  -fx G
[Fractal] [Noise] [Noise]
色相
  -blur 0x10 -auto-level -separate -background white \
     -compose ModulusAdd -flatten -channel R -combine +channel \
     -set colorspace HSB -colorspace RGB
[Fractal] [Noise] [Noise]
陰影轉換
陰影_原始 (無後 - 自動電平)
  -shade 120x45
[Fractal] [Noise] [Noise]
陰影
  -shade 120x45
[Fractal] [Noise] [Noise]
陰影_暗化 (無後 - 自動電平)
  -shade 120x45 -auto-level -fill grey -colorize 40%
[Fractal] [Noise] [Noise]
陰影_1
  -blur 0x1 -shade 120x45
[Fractal] [Noise] [Noise]
陰影_2
  -blur 0x2 -shade 120x45
[Fractal] [Noise] [Noise]
陰影_5
  -blur 0x5 -shade 120x45
[Fractal] [Noise] [Noise]
陰影_10
  -blur 0x10 -fx G -shade 120x45
[Fractal] [Noise] [Noise]
浮雕轉換
浮雕_1
  -blur 0x5  -emboss 1
[Fractal] [Noise] [Noise]
浮雕_1g
  -blur 0x5  -emboss 1  -fx G
[Fractal] [Noise] [Noise]
浮雕_0s
  -blur 0x3  -emboss .5 -shade 120x45
[Fractal] [Noise] [Noise]
浮雕_1s
  -blur 0x5  -emboss 1  -shade 120x45
[Fractal] [Noise] [Noise]
浮雕_1gs
  -blur 0x5  -emboss 1  -fx G  -shade 120x45
[Fractal] [Noise] [Noise]
浮雕_5gs
  -blur 0x10 -emboss 5  -fx G  -shade 120x45
[Fractal] [Noise] [Noise]
邊緣轉換
炭筆
  -blur 0x2  -charcoal 10 -negate
[Fractal] [Noise] [Noise]
炭筆_10s
  -blur 0x2  -charcoal 10 -negate -shade 120x45
[Fractal] [Noise] [Noise]
炭筆_1s
  -blur 0x2  -charcoal 1  -negate -shade 120x45
[Fractal] [Noise] [Noise]
邊緣
  -blur 0x2  -edge 10
[Fractal] [Noise] [Noise]
邊緣_灰色
  -blur 0x2  -edge 10 -fx G
[Fractal] [Noise] [Noise]
台地
  -blur 0x2  -edge 10 -fx G -shade 120x45
[Fractal] [Noise] [Noise]
線條生成轉換
線條
  -blur 0x10 -emboss 4 -edge 1
[Fractal] [Noise] [Noise]
迴圈
  -blur 0x10 -edge 15  -edge 1  -blur 0x1
[Fractal] [Noise] [Noise]
雕刻_迴圈
  -blur 0x10 -edge 15  -edge 1  -blur 0x1 -fx R+B+G -shade 280x45
[Fractal] [Noise] [Noise]
雕刻_迴圈
  -blur 0x10 -edge 15  -edge 1  -blur 0x1 -fx G -shade 280x45
[Fractal] [Noise] [Noise]
彩色_輪廓
  -blur 0x10 -normalize -fx 'sin(u*4*pi)*100' -edge 1 -blur 0x1
[Fractal] [Noise] [Noise]
輪廓
  -blur 0x10 -normalize -fx 'sin(g*4*pi)*100' \
     -edge 1 -blur 0x1 -shade 280x45
[Fractal] [Noise] [Noise]
複雜紋理斑點轉換
(使用奇怪的「-edge 1」效果)
斑點
  -blur 0x10 -edge 1
[Fractal] [Noise] [Noise]
斑點_灰色
  -blur 0x10 -edge 1 -fx '(R+G+B)/3'
[Fractal] [Noise] [Noise]
凹坑
  -blur 0x10 -edge 1 -fx G -shade 280x45
[Fractal] [Noise] [Noise]
山脊
  -blur 0x10 \( +clone -negate \) -edge 1 -fx u.G+v.G -shade 280x45
[Fractal] [Noise] [Noise]
斑駁
  -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]
繪畫轉換
繪畫_原始10 (無後 - 自動電平)
  -paint 10
[Fractal] [Noise] [Noise]
繪畫_區域
  -paint 10  -blur 0x5  -paint 10
[Fractal] [Noise] [Noise]
繪畫_原始10s
  -paint 10  -shade 120x45
[Fractal] [Noise] [Noise]
繪畫_8
  -blur 0x5  -paint 8
[Fractal] [Noise] [Noise]
繪畫_8s
  -blur 0x5  -paint 8  -shade 120x45
[Fractal] [Noise] [Noise]
繪畫_3
  -blur 0x10 -paint 3
[Fractal] [Noise] [Noise]
繪畫_3s
  -blur 0x10 -paint 3  -shade 120x45
[Fractal] [Noise] [Noise]
繪畫_3d
  -blur 0x10 -paint 3 \( +clone -shade 120x45 \) \
     +swap  -compose overlay -composite
[Fractal] [Noise] [Noise]
漸層轉換
電平 (無後 - 自動電平)
  -blur 0x12 -fx intensity -normalize \
     -size 1x9 gradient:navy-lavender \
     -interpolate integer -fx 'v.p{0,G*(v.h-1)}'
[Fractal] [Noise] [Noise]
電平_3d (無後 - 自動電平)
  -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]
斑馬線
  -blur 0x12 -normalize \
     -size 1x19   pattern:gray50   -fx 'v.p{0,G*(v.h-1)}'
[Fractal] [Noise] [Noise]
中電平
  -blur 0x12 -normalize \
     \( -size 1x9 xc: -draw 'color 0,4 point' -negate \) \
     -fx 'v.p{0,G*(v.h-1)}'
[Fractal] [Noise] [Noise]
邊緣_電平 (無後 - 自動電平)
  -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]
分層_電平 (無後 - 自動電平)
  -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]
其他
細絲
  -blur 0x5 -normalize -fx g \
     -sigmoidal-contrast 15x50% -solarize 50%
[Fractal] [Noise] [Noise]

如果您有或想出一個不錯的背景生成器或圖像轉換,請告訴我,以便將其添加到此處與他人分享。

最後的重要注意事項

兩個 隨機雜訊影像 因為其「隨機性」,所以是可以平鋪的,我們使用「-virtual-pixels」來確保它們在轉換過程中保持可平鋪性。 然而,電漿影像 一開始就不是可以平鋪的,所以會使用「-shave」將邊緣「剃掉」的放大版本,來消除許多操作中不希望出現的邊緣效應。 這項技術會在 修改平鋪影像 中進一步討論。 請注意,最終的「-auto_level」會應用於大多數影像,以增強結果的對比度,除非轉換被標記為不需要這樣做,以便保留轉換產生的顏色或陰影。 由於許多影像轉換(例如「-blur」、「-emboss」和「-edge」)是灰階轉換,因此它們會完全獨立地作用於三個色彩通道。 因此,在許多影像中,結果看起來就像三個獨立的影像被疊加在一起,然後進行了陰影處理。 最後的「layered_levels」範例旨在同時作用於三個色階,同時將它們保持分離,直到最後一步將它們加在一起並進行顏色著色。 這種三重效果可以透過套用初始灰階處理操作或在完成後僅提取其中一個通道來消除。 通常我會提取「green」或「G」通道,因為它通常是灰階影像中最強的通道,但也可以使用三個通道中的任何一個。