mapbox / pixelmatch

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

Image data: Uint8Array, Uint8ClampedArray or Buffer expected. #116

Closed IamMille closed 2 years ago

IamMille commented 2 years ago

In the Node.js example, it seems like the const diff = new PNG({width, height}); returns a stream, hence the error.

mourner commented 2 years ago

That stream also has a data property (per pngjs docs), so the example works as expected.

pixelmatch(img1.data, img2.data, diff.data, width, height, {threshold: 0.1});
mourner commented 2 years ago

@gsouf 🤷‍♂️ you could submit an issue to pngjs, but their docs are clear: https://github.com/lukeapage/pngjs#pngsyncreadbuffer

gsouf commented 2 years ago

@mourner sorry I just made something wrong and because I found this 3 days old issue I just assumed there was a recent bug