Closed MrBiscuit closed 2 years ago
The input for image data assumes 4 values (R, G, B, A) for each pixel. This is why the library has this condition on input:
https://github.com/mapbox/pixelmatch/blob/b9261a447515f5aff37a15cfab9f4a491868f720/index.js#L23
Make sure your input images data lenth equals width * height * 4
.
I was using sharp package; and during test i was getting "Image Size doesn't match" Error and i fixed it using .ensureAlpha()
referenced from https://github.com/mapbox/pixelmatch/issues/114 e.g
const boxedBuffer1 = await sharp1 .resize({ width: maximumWidth, height: maximumHeight, fit: 'contain', position: 'left top' }) .raw() .ensureAlpha() .toBuffer();
I get countless
Image data size does not match width/height
andImage sizes do not match
error even calling the function as simple aspixelmatch(new Uint8Array(2),new Uint8Array(2),null)
assigning width height or notEven passing in the same image for both img1 and img2 arguments, will forever raise this
Image data size does not match width/height
error no matter what.Please help, I never get this to work