mapbox / pixelmatch

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

Optimized Image's Unit8Array data length is always smaller than w*h*4 #102

Closed MrBiscuit closed 2 years ago

MrBiscuit commented 2 years ago

I did read everything in the readme and all the past issues (open+closed) before raising the issue, so please don't judge me by the cover 🙏🏻 For a 100x100 optimized PNG image, The more complex it is, the closer it gets to 40000 length, but mostly it won't come close, see examples provided below(all of them are 100x100):

cc ^ This one has a length of 31818

23 ^ This one has a length of 20205

Rectangle ^This one has a length of 10377

img1 ^ This one has a length of 492

Rectangle 4 ^ This one has a length of 345

mourner commented 2 years ago

Please read the readme examples carefully and stop spamming new issues. You're passing encoded PNG buffer as input, whereas you need to decode the image first, and pass the pixel data.