gemini-testing / looks-same

Node.js library for comparing images
MIT License
669 stars 55 forks source link

Compatibility with sharp > 0.32.6 #102

Closed gugu closed 8 months ago

gugu commented 8 months ago

When I run tests on sharp v0.33 the library fails with SIGABRT

Example: https://github.com/Short-io/qr-image (npm test)

DudaGod commented 8 months ago

Hello, sorry for long response.

https://github.com/Short-io/qr-image (npm test)

I can't install deps in your package in my mac m1. Can you provide a minimal reproducible example?

When I run tests on sharp v0.33 the library fails with SIGABRT

Can you provide a full logs with this error?

gugu commented 8 months ago
  1. I've changed test dependency canvas to @napi-rs/canvas (not related to the module), now it builds and arms
  2. RangeError {
    code: 'ERR_BUFFER_OUT_OF_BOUNDS',
    message: 'Attempt to access memory outside buffer bounds',
    }
    
    RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to access memory outside buffer bounds
      at boundsError (node:internal/buffer:86:11)
      at Buffer.readUInt32BE (node:internal/buffer:311:5)
      at get width [as width] (/Users/k/dev/w/qr-image/node_modules/looks-same/lib/img-buffer/original-buffer.js:14:29)
      at looksSame (/Users/k/dev/w/qr-image/node_modules/looks-same/index.js:174:58)
      at assertEqual (/Users/k/dev/w/qr-image/src/tests/_common.ts:19:23)
      at <anonymous> (/Users/k/dev/w/qr-image/src/tests/test.ts:248:9)
DudaGod commented 8 months ago

Can you provide images/buffers on which this error - [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to access memory outside buffer bounds occurs?

gugu commented 8 months ago

This one: https://github.com/Short-io/qr-image/blob/master/test_data/golden/qr_with_logo_jpg.png You can compare it with itself

DudaGod commented 8 months ago

This one: https://github.com/Short-io/qr-image/blob/master/test_data/golden/qr_with_logo_jpg.png You can compare it with itself

Hm, I can't reproduce the problem you described. Are you using the latest version of looks-same?

gugu commented 8 months ago

The problem was because two version of sharp installed (0.32 and 0.33), this helps:

    "overrides": {
        "sharp": "$sharp"
    },