mapbox / pixelmatch

The smallest, simplest and fastest JavaScript pixel-level image comparison library
ISC License
6.17k stars 307 forks source link

Comparing buffers #76

Closed philmirez closed 5 years ago

philmirez commented 5 years ago

Hello 👋

I would like to compare two images in memory as opposed to relying on reading and writing from the file system.

I might be going about this the wrong way and if so I'd appreciate some sort of hint/help.

I've created a repo showcasing what I'm seeing: https://github.com/philmirez/comparing-buffers

Side note: One thing that threw me off was when I was reading the pixelmatch/index.js file, it says...

if (img1.length !== width * height * 4) throw new Error('Image data size does not match width/height.')

I don't understand why width and height are being multiplied by 4.

philmirez commented 5 years ago

Never mind, I was able to find help on stackoverflow.