用imageMagick的composite合并图片

这篇博客介绍了如何利用imageMagick的composite命令来合并图片,特别适用于添加水印和批量处理图像。通过设置-gravity参数,可以将前景图片放置在背景图片的不同位置,如north、center或southeast。结合-geometry选项,可以实现更精确的图像定位。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

composite命令可以非常方便的合并两张图片

因此用来进行图像加水印、批量增加边框等常用的变换

 

最简单的用法为:

composite -gravity north src.jpg coverback.jpg des.jpg

 

其中src.jpg为前景图片

coverback.jpg为背景图片。

des.jpg为叠加后的结果

 

-gravity north 指叠加位置为垂直据顶部、水平居中(正北方向)

如果要求在正中间,参数为center

如果要求在右下角,参数为southeast

 

composite还提供更灵活的定位,可以使用 -geometry 配置

 

具体的composite参数表见下表

 

 

-affine matrix

affine transform matrix
-alphaon, activate, off, deactivate, set, opaque, copy", transparent, extract, background, or shape the alpha channel
-authenticate valuedecrypt image with this password
-blend geometryblend images
-blue-primary pointchromaticity blue primary point
-border geometrysurround image with a border of color
-bordercolor colorborder color
-channel typeapply option to select image channels
-colors valuepreferred number of colors in the image
-colorspace typeset image colorspace
-comment stringannotate image with comment
-compose operatorset image composite operator
-compress typeimage compression type
-debug eventsdisplay copious debugging information
-decipher filenameconvert cipher pixels to plain
-define format:optiondefine one or more image format options
-density geometryhorizontal and vertical density of the image
-depth valueimage depth
-displace geometryshift image pixels defined by a displacement map
-dissolve valuedissolve the two images a given percent
-dither methodapply error diffusion to image
-encipher filenameconvert plain pixels to cipher pixels
-encoding typetext encoding type
-endian typeendianness (MSB or LSB) of the image
-extract geometryextract area from image
-filter typeuse this filter when resizing an image
-font namerender text with this font
-geometry geometrypreferred size or location of the image
-gravity typehorizontal and vertical text placement
-green-primary pointchromaticity green primary point
-helpprint program options
-identifyidentify the format and characteristics of the image
-interlace typetype of image interlacing scheme
-interpolate methodpixel color interpolation method
-label stringassign a label to an image
-level valueadjust the level of image contrast
-limit type valuepixel cache resource limit
-log formatformat of debugging information
-monitormonitor progress
-monochrometransform image to black and white
-negatereplace each pixel with its complementary color
-page geometrysize and location of an image canvas (setting)
-pointsize valuefont point size
-profile filenameadd, delete, or apply an image profile
-quality valueJPEG/MIFF/PNG compression level
-quantize colorspacereduce image colors in this colorspace
-quietsuppress all warning messages
-red-primary pointchromaticity red primary point
-regard-warningspay attention to warning messages.
-respect-parenthesessettings remain in effect until parenthesis boundary.
-rotate degreesapply Paeth rotation to the image
-sampling-factor geometryhorizontal and vertical sampling factor
-scene valueimage scene number
-seed valueseed a new sequence of pseudo-random numbers
-set attribute valueset an image attribute
-sharpen geometrysharpen the image
-shave geometryshave pixels from the image edges
-size geometrywidth and height of image
-stegano offsethide watermark within an image
-stereo geometrycombine two image to create a stereo anaglyph
-stripstrip image of all profiles and comments
-swap indexesswap two images in the image sequence
-synchronizesynchronize image to storage device
-taintmark the image as modified
-thumbnail geometrycreate a thumbnail of the image
-tilerepeat composite operation across and down image
-transformaffine transform image
-transparent-color colortransparent color
-treedepth valuecolor tree depth
-type typeimage type
-units typethe units of image resolution
-unsharp geometrysharpen the image
-verboseprint detailed information about the image
-versionprint version information
-virtual-pixel methodaccess method for pixels outside the boundaries of the image
-watermark geometrypercent brightness and saturation of a watermark
-white-point pointchromaticity white point
-white-threshold valueforce all pixels above the threshold into white
-write filenamewrite images to this file
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值