javascript 使用 graphicsmagick 在 nodejs 上创建图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9639424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
create image on nodejs with graphicsmagick
提问by Lupus
I need a way to create an image on graphicsMagick via node.js
我需要一种通过 node.js 在 graphicsMagick 上创建图像的方法
Normally I can manage this with;
通常我可以用;
gm convert -background transparent -pointsize 30 -gravity Center label:türk?ee HEEEEEY.png
I need the equivalent of this input in node.js like;
我需要在 node.js 中等效于此输入;
var gm = require('gm');
gm.background('transparent')
.gravity('Center')
.fontSize(30)
.drawText('Test')
.write('HEEEY.png')
PS: I don't want to give image size as parameter. (sorry for my english)
PS:我不想将图像大小作为参数。(对不起我的英语不好)
回答by Linus Gustav Larsson Thiel
Look in the node-grapicksmagick README, under "creating an image".
查看node-grapicksmagick README,在“创建图像”下。
// creating an image
gm(200, 400, "#ddff99f3")
.drawText(10, 50, "from scratch")
.write("/path/to/brandNewImg.jpg", function (err) {
// ...
});