如何使用 Node.js 动态创建图像? [英] How to create an image on the fly with Node.js?
问题描述
我正在使用 Node.js 和 Express Web 框架,我需要创建一个动态图像 .png 或 .jpg(如验证码),然后我必须将该图像发送到浏览器.
I'm using Node.js and Express web framework, I need to create an on-the-fly image .png or .jpg (like captcha), then I have to send that image to the browser.
最简单的方法是什么?在图片中我应该写字母/数字(最多 5 个).
What is the simplest way to do that? In the image I should write letters/numbers (max 5).
附言我不知道要使用哪个库来像 recaptcha 模块那样连接到在线服务.
P.S. I don't know what library to use that connects to an online service as the recaptcha module does.
推荐答案
也许你可以使用 canvas?还有一个 Learnboost(TJ) 在 node.js 中的实现.我认为这个截屏视频很有趣.正如您从演示中看到的,它甚至在某些示例中呈现文本.同样在 npm 注册表/节点模块部分 我发现了更多有趣的链接
Maybe you could use canvas? There is also an implementation in node.js by Learnboost(TJ). I think this screencast is interesting to look at. As you see from presentation it even renders text in some examples. Also in the npm registry / node modules section I found a lot more interesting links
这篇关于如何使用 Node.js 动态创建图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!