Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Ignorable areas #9

Open
alexwhitman opened this issue Feb 23, 2012 · 5 comments
Open

[Feature request] Ignorable areas #9

alexwhitman opened this issue Feb 23, 2012 · 5 comments

Comments

@alexwhitman
Copy link

Would it be possible to implement the ability to ignore areas of an image when diff'ing? For example, if I have an image of a web page which I want to compare against a baseline image I might want to ignore certain areas, such as dynamic text or images.

This could be done by specifying rectangle areas to ignore with top left x and y coordinates and bottom right x and y coordinates.

@cesutherland
Copy link
Member

The easiest thing to do would be to white-out those areas before doing the diff. Might be beyond the scope of this tool, but I'll think on it.

@jreichenberg
Copy link

+1 on this feature request...For automated testing it would be really excellent to be able to define a region to diff. Maybe a reasonable MVP would be something as simple as an option to say "region": ["0,0", "200,100"] to specify the top left and bottom right corners of the diffable region.

Great project!

@baartz
Copy link

baartz commented Oct 29, 2014

Agreed. Exclusion areas would be outstanding.

@hayesmaker
Copy link

👍 +1

@subhog
Copy link

subhog commented Sep 14, 2016

I've added a pull request with this feature: #58.

The equal method accepts regions option. If passed, an initially empty mask is generated that describes which part of images to compare. regions is an array of rectangles, each rectangle passed in the form [x0, y0, x1, y1, include], where include decides on whether the rectangle should be added to the mask (and compared), or subtracted from the mask (and ignored). Example:

equal(a, b, 0, {regions: [
    [20,  200, 220, 500, true],
    [60,  400, 80,  420, false],
    [160, 400, 180, 420, false],
]})

will check the "face", but not the "eyes".

I didn't want to change the existing API in the PR, but I also suggest that the tolerance parameter should go inside the options object.

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

No branches or pull requests

6 participants