How to use the diff function from jimp
Find comprehensive JavaScript jimp.diff code examples handpicked from public code repositorys.
1708 1709 1710 1711 1712 1713 1714 1715 1716 1717if (msg.attachments.length===2&&msg.attachments[0].content_type.startsWith('image/')&&msg.attachments[1].content_type.startsWith('image/')){ var attachmentsUrls = msg.attachments.map((u)=>{return u.proxy_url}) jimp.read(attachmentsUrls[0], (err,img1)=>{ jimp.read(attachmentsUrls[1], (err,img2)=>{ var distance = jimp.distance(img1,img2) var diff = jimp.diff(img1,img2) var newMsg = 'Image 1 hash: `'+img1.hash()+'`\nImage 2 hash: `'+img2.hash()+'`\nHash Distance: `'+distance+'`\nImage Difference: `'+diff.percent*100+' %`' diff.image.getBuffer(jimp.MIME_PNG, (err,buffer)=>{ if(err){debugLog(err)} try{bot.createMessage(msg.channel.id, newMsg, {file: buffer, name: 'imgdiff.png'})}catch(err){debugLog(err)}
715 716 717 718 719 720 721 722 723 724// The threshold parameter affects the sensitivity of individual pixel // comparisons. This diff is only used for visual review, not for // automated similarity checks, so the threshold setting is not so critical // as it used to be. const threshold = 0.10; const diff = Jimp.diff(oldScreenshot, newScreenshot, threshold); // Write the diff to disk. This is used to review when there are changes. const fullSizeDiff = diff.image.clone().resize(width, height, Jimp.RESIZE_BICUBIC);
+ 10 other calls in file