Closed MrBiscuit closed 2 years ago
Gosh. Can you at least take a look at the examples in the readme before opening issues? Pixelmatch accepts pixel data as input, so a 100x100 image will have exactly 40000 length, unless you forgot to decode your PNG.
Let's say the image is a 100x100 pixels pure black square PNG, and I type
100
for thewidth
parameter and100
for theheight
parameter, and it still throws 'Image data size does not match width/height.'When I console.log the 100x100 pure black PNG
Unit8Array.length
, it gives345
So then I typedMath.sqrt(Unit8Array.length/4)
for width and height parameters and it works, however, adding a 10x10 red square inside (in the center) the 100x100 black square results in aUnit8Array.length
of378
instead of345
.Am I supposed to input
sqrt((img1.length+img2.length)/2/4)
? Even so,img2
won't have the same exactlength
asimg1
and it will throwImage sizes do not match