简体   繁体   中英

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

I'm making a bot in Discord, to mostly goof. I decided to create a "deep-fry" command:

// 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'
        ]
      })
    })
}

I noticed that, in comparision with other deep-fried images, its missing some noise. I couldn't find anything about applying it (well, using Jimp), any ideas on how could i apply some?

I'm not very familliar with Jimp, but from reading the docs you could try some of the following;

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM