gm("img.png").append(img [, img, ltr])
gm("img.png").append("another.jpg", "third.gif")//从上到下拼接
gm("img.png").append("another.jpg", "third.gif", true)//从左到右拼接图片注释
在图片的(x, y)位置绘制文字。
gm("img.png").drawText(10, 50, "from scratch")创建图片
gm(200, 400, "#ddff99f3")
.drawText(10, 50, "from scratch")
.write("/path/to/brandNewImg.jpg", function (err) {
// ...
});总结
gm具有强大的图片处理功能,nodejs还是借助于gm工具来实现的图片处理,对于需要后台处理图片的情形,这个是挺有用的。
gm提供的各个函数其实可以复合使用,就是说,先读取(gm)图片后,可以先进行拼接(mosaic, compose, append),然后裁剪(crop),放缩(resize)到指定大小后,最后才保存(write)下来。
gm的官方文档感觉过于简陋,网上的关于nodejs gm用法的资料也不多,本文将一些基本的用法总结下来,学到到新的持续更新。
另外,欢迎大家总结nodejs gm资料!
附gm参考资料
node gm github
nodejs gm官方文档
stackoverflow : How to do composite with gm node.js?









