是否可以在Node.js中使用Jimp为图片添加噪点?

Is it possible to add noise to the picture using Jimp in Node.js?

我正在 Discord 中制作一个机器人,主要是为了搞笑。 我决定创建一个 "deep-fry" 命令:

// stuff here
function deepfry(link) {
  var pixelValue = Math.floor(Math.random() * 2 + 2)
    Jimp.read(link)
    .then(image => {
      image
      .pixelate(pixelValue)
      .contrast(0.95)
      .write('./images/deepfry.png')
      message.channel.send({
        files: [
          './images/deepfry.png'
        ]
      })
    })
}

我注意到,与其他油炸图像相比,它缺少一些噪音。我找不到任何关于应用它的信息(好吧,使用 Jimp),关于我如何应用它的任何想法?

我对 Jimp 不是很熟悉,但是通过阅读文档,您可以尝试以下一些方法;

image.posterize( n );
image.sepia();