ImageMagick 示例 -- 背景
ImageMagick 示例 前言与索引
这是一张对若干『随机』画布应用各种变换的一览表,展示了如何生成有趣的随机背景,尺寸可随意设定,无论是单幅大图,还是网页用的背景平铺块。表格从生成最初那幅『随机』图像的方法开始,此后展示的所有图像都由它生成。你只需把各种图像『变换』插入命令中,就能用 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%
如果你有或想到了不错的背景生成器或图像变换,请告诉我,以便添加到这里与他人分享。
最后的重要说明
那两幅随机噪声图像由于极为『随机』,是可平铺的,我们使用 "[-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' 通道,因为它在灰度图像中一般是最强的通道,不过三个通道中的任何一个都可以使用。
![[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)