Skip to content

feat: Add options.ignoreMask of pixels to skip - #171

Open
Venefilyn wants to merge 1 commit into
mapbox:mainfrom
Venefilyn:feat/ignore-areas
Open

Venefilyn wants to merge 1 commit into
mapbox:mainfrom
Venefilyn:feat/ignore-areas

Conversation

@Venefilyn

Copy link
Copy Markdown

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: #163
Supercedes: #153
Signed-off-by: Freya Gustavsson freya@venefilyn.se

@Venefilyn
Venefilyn requested a review from a team as a code owner September 7, 2026 13:15
@Venefilyn
Venefilyn requested review from stepankuzmin and removed request for a team September 7, 2026 13:15
@ox-security

ox-security Bot commented Sep 7, 2026

Copy link
Copy Markdown

OX Security Logo

OX Security reviewed this pull request — nothing to fix.

No issues found

Branch feat/ignore-areasmain

View scan in OX Security →

@mourner mourner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@Venefilyn

Copy link
Copy Markdown
Author

Looks like a bunch of tests are failing — let's make sure the CI is green first

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]) {

Comment thread index.js
const b32 = new Uint32Array(img2.buffer, img2.byteOffset, len);
const ignoreMask32 = ignoreMask ?
new Uint32Array(ignoreMask.buffer, ignoreMask.byteOffset, len) :
null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread index.js

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; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks buggy — if pixels differ but there's no mask, the loop keeps going and reports identical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support exclusion zones

2 participants