composite命令可以非常方便的合并两张图片
因此用来进行图像加水印、批量增加边框等常用的变换
最简单的用法为:
composite -gravity north src.jpg coverback.jpg des.jpg
其中src.jpg为前景图片
coverback.jpg为背景图片。
des.jpg为叠加后的结果
-gravity north 指叠加位置为垂直据顶部、水平居中(正北方向)
如果要求在正中间,参数为center
如果要求在右下角,参数为southeast
composite还提供更灵活的定位,可以使用 -geometry 配置
具体的composite参数表见下表
|
affine transform matrix |
-alpha | on, activate, off, deactivate, set, opaque, copy", transparent, extract, background, or shape the alpha channel |
-authenticate value | decrypt image with this password |
-blend geometry | blend images |
-blue-primary point | chromaticity blue primary point |
-border geometry | surround image with a border of color |
-bordercolor color | border color |
-channel type | apply option to select image channels |
-colors value | preferred number of colors in the image |
-colorspace type | set image colorspace |
-comment string | annotate image with comment |
-compose operator | set image composite operator |
-compress type | image compression type |
-debug events | display copious debugging information |
-decipher filename | convert cipher pixels to plain |
-define format:option | define one or more image format options |
-density geometry | horizontal and vertical density of the image |
-depth value | image depth |
-displace geometry | shift image pixels defined by a displacement map |
-dissolve value | dissolve the two images a given percent |
-dither method | apply error diffusion to image |
-encipher filename | convert plain pixels to cipher pixels |
-encoding type | text encoding type |
-endian type | endianness (MSB or LSB) of the image |
-extract geometry | extract area from image |
-filter type | use this filter when resizing an image |
-font name | render text with this font |
-geometry geometry | preferred size or location of the image |
-gravity type | horizontal and vertical text placement |
-green-primary point | chromaticity green primary point |
-help | print program options |
-identify | identify the format and characteristics of the image |
-interlace type | type of image interlacing scheme |
-interpolate method | pixel color interpolation method |
-label string | assign a label to an image |
-level value | adjust the level of image contrast |
-limit type value | pixel cache resource limit |
-log format | format of debugging information |
-monitor | monitor progress |
-monochrome | transform image to black and white |
-negate | replace each pixel with its complementary color |
-page geometry | size and location of an image canvas (setting) |
-pointsize value | font point size |
-profile filename | add, delete, or apply an image profile |
-quality value | JPEG/MIFF/PNG compression level |
-quantize colorspace | reduce image colors in this colorspace |
-quiet | suppress all warning messages |
-red-primary point | chromaticity red primary point |
-regard-warnings | pay attention to warning messages. |
-respect-parentheses | settings remain in effect until parenthesis boundary. |
-rotate degrees | apply Paeth rotation to the image |
-sampling-factorgeometry | horizontal and vertical sampling factor |
-scene value | image scene number |
-seed value | seed a new sequence of pseudo-random numbers |
-set attribute value | set an image attribute |
-sharpen geometry | sharpen the image |
-shave geometry | shave pixels from the image edges |
-size geometry | width and height of image |
-stegano offset | hide watermark within an image |
-stereo geometry | combine two image to create a stereo anaglyph |
-strip | strip image of all profiles and comments |
-swap indexes | swap two images in the image sequence |
-synchronize | synchronize image to storage device |
-taint | mark the image as modified |
-thumbnail geometry | create a thumbnail of the image |
-tile | repeat composite operation across and down image |
-transform | affine transform image |
-transparent-colorcolor | transparent color |
-treedepth value | color tree depth |
-type type | image type |
-units type | the units of image resolution |
-unsharp geometry | sharpen the image |
-verbose | print detailed information about the image |
-version | print version information |
-virtual-pixel method | access method for pixels outside the boundaries of the image |
-watermarkgeometry | percent brightness and saturation of a watermark |
-white-point point | chromaticity white point |
-white-thresholdvalue | force all pixels above the threshold into white |
-write filename | write images to this file |