⚠️ 这是一个非官方翻译网站,与 ImageMagick Studio LLC 无关。准确信息请参阅原文(https://usage.imagemagick.org/backgrounds/index.html)

ImageMagick 示例 -- 背景

ImageMagick 示例 前言与索引 这是一张对若干『随机』画布应用各种变换的一览表,展示了如何生成有趣的随机背景,尺寸可随意设定,无论是单幅大图,还是网页用的背景平铺块。表格从生成最初那幅『随机』图像的方法开始,此后展示的所有图像都由它生成。你只需把各种图像『变换』插入命令中,就能用 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]

如果你有或想到了不错的背景生成器或图像变换,请告诉我,以便添加到这里与他人分享。

最后的重要说明

那两幅随机噪声图像由于极为『随机』,是可平铺的,我们使用 "[-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)" 等许多图像变换都是灰度变换,它们会对三个颜色通道彼此完全独立地起作用。因此,在许多图像中,结果看起来就像是三幅各自独立的图像被叠加在一起并施加了阴影。最后的示例 "layered_levels" 经过专门设计,会同时作用于三个层级,同时又让它们保持分离,直到最后一步才将它们相加并进行色彩着色。要去除这种三重效果,可以在开始时先应用一次灰度化操作,或者在完成后只提取其中一个通道。我通常提取 'green' 即 'G' 通道,因为它在灰度图像中一般是最强的通道,不过三个通道中的任何一个都可以使用。