【问题标题】:Blurring image with canvas nodeJS使用画布 nodeJS 模糊图像
【发布时间】:2021-02-19 12:08:40
【问题描述】:

似乎ctx.filter = "blur(amount)" 不起作用。这是我的代码:

const {
    body
} = await request.get(
    url
);
const data = await Canvas.loadImage(body);
ctx.filter = "blur(50px)"
ctx.drawImage(data, 0, 0, canvas.width, canvas.heigth)
const final = new Discord.MessageAttachment(
    canvas.toBuffer(),
    "blurred.png"
);

是的,这是为了 Discord。

【问题讨论】:

标签: javascript node.js canvas


【解决方案1】:

确实他们仍然不支持此功能。
Here is the issue tracking the feature request.

显然,这些过滤器不是内置 Cairo(node-canvas 使用的渲染引擎),但 Skia(node-canvas 可以在不久的将来切换到的另一个渲染引擎)显然是内置的。所以总有一天会有希望,但暂时还得自己去实现。

对于高斯模糊,您可以查看StackBlur.js 项目,这是浏览器原生实现之前事实上的模糊滤镜库。这里以glitch project 为例。

【讨论】:

    猜你喜欢
    • 2013-07-25
    • 1970-01-01
    • 1970-01-01
    • 2015-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-04
    • 1970-01-01
    相关资源
    最近更新 更多