How to use the distance function from jimp
Find comprehensive JavaScript jimp.distance code examples handpicked from public code repositorys.
1707 1708 1709 1710 1711 1712 1713 1714 1715 1716
case '!imgdiff':{ if (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)}
22
101
3