我使用graphicmagic从nodejs返回图像非常困难.浏览器挂在流上.
我已经引用了NodeJS gm调整大小和管道响应,但我仍然无法使其工作.
gm = require('gm');
app.get('/text', function (req, res)
{
gm(200, 400, "#ddff99f3")
.drawText(10, 50, "from scratch")
.stream('png', function (err, stdout, stderr) {
stdout.pipe(res);
});
});
Run Code Online (Sandbox Code Playgroud)
看起来您没有设置适当的内容类型:
res.set('Content-Type', 'image/png'); // set the header here
Run Code Online (Sandbox Code Playgroud)
做到这一点之前调用gm.drawText
| 归档时间: |
|
| 查看次数: |
1430 次 |
| 最近记录: |