Conversation
|
OX Security reviewed this pull request — nothing to fix.
Branch |
mourner
left a comment
There was a problem hiding this comment.
Looks like a bunch of tests are failing — let's make sure the CI is green first
New check where if a value from `ignoreMask` is greater than 0 it will be ignored from the check. The ignore mask itself needs to be exact width and height of the images provided. One could write an array manually or provide a PNG image with RGBA(0,0,0,0) for pixels to check and any other color value for what to skip. Fixes: mapbox#163 Supercedes: mapbox#153 Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
722d8a9 to
f3ee790
Compare
Woops, was refactoring and made a mistake in the if-statement. Should've been - if (!inIgnoreMask && a32[i] === b32[i]) {
+ if (!inIgnoreMask && a32[i] !== b32[i]) { |
| const b32 = new Uint32Array(img2.buffer, img2.byteOffset, len); | ||
| const ignoreMask32 = ignoreMask ? | ||
| new Uint32Array(ignoreMask.buffer, ignoreMask.byteOffset, len) : | ||
| null; |
There was a problem hiding this comment.
I wonder if this is too limiting — accepting RGBA as input mask if we only need 0/1 over each pixel. Also non-zero Uint32 fails for cases like 255,255,255,0 where a pixel is invisible in a mask image but still gets treated as masked. Maybe let's simplify this and accept Uint8Array(width * height) directly, one value per pixel?
This way we loose the ability to pass PNG data directly as mask (needs a small helper) but I think that's fine, and gives more flexibility — e.g. we could also use masks defined as black/white rather than transparent / opaque.
|
|
||
| for (let i = 0; i < len; i++) { | ||
| if (a32[i] !== b32[i]) { identical = false; break; } | ||
| if (a32[i] !== b32[i] && ignoreMask32?.[i] !== 0) { identical = false; break; } |
There was a problem hiding this comment.
This looks buggy — if pixels differ but there's no mask, the loop keeps going and reports identical.
New check where if a value from
ignoreMaskis greater than 0 it willbe ignored from the check. The ignore mask itself needs to be exact
width and height of the images provided.
One could write an array manually or provide a PNG image with
RGBA(0,0,0,0) for pixels to check and any other color value for what
to skip.
Fixes: #163
Supercedes: #153
Signed-off-by: Freya Gustavsson freya@venefilyn.se