looks-same icon indicating copy to clipboard operation
looks-same copied to clipboard

Feature: ignore rectangle

Open skyiea opened this issue 7 years ago • 5 comments

Does looks-same support ignoring certain areas (rectangles) during comparison? I see that gemini, which is using looks-same, allows to ignoreElements. I would expect it (ignoring) is done by means of image-comparison tool?

skyiea avatar Dec 24 '17 12:12 skyiea

Similarly, I'd love to have a whitelist of comparison zones too!

scottrippey avatar Mar 21 '19 05:03 scottrippey

Hello.

At the moment looks-same is able to compare by regions:

looksSame({source: 'img1', boundingBox: {left: 10, top: 10, right: 20, bottom: 20}}, {source: 'img2', boundingBox: {left: 30, top: 30, right: 40, bottom: 40}}, {...opts}, callback)

But not able to ignore some region. Add this logic is not really difficult looking at this PR - https://github.com/gemini-testing/looks-same/pull/51. Do you have some free time to contribute? ;)

DudaGod avatar Mar 21 '19 06:03 DudaGod

You can define your ignoring rectangles and then if diffClusters are within those ignoring rectangles you just change equal to true.

looksSame('image1.png', 'image2.png', {stopOnFirstFail: false}, function(error, {equal, diffBounds, diffClusters}) {
    // {
    //     equal: false,
    //     diffBounds: {left: 10, top: 10, right: 20, bottom: 20}
    //     diffClusters: [
    //         {left: 10, top: 10, right: 14, bottom: 14}, // Compare this
    //         {left: 16, top: 16, right: 20, bottom: 20}  // to your  ignoring rectangles
    //     ]
    // }
});

krgolovan avatar Mar 27 '19 18:03 krgolovan

To my mind it's not the best solution. It would be much better if looks-same provided API to ignore some areas.

DudaGod avatar Mar 27 '19 21:03 DudaGod

To my mind it's not the best solution. It would be much better if looks-same provided API to ignore some areas.

Right! I meant as a temporary solution you can use diffClusters.

krgolovan avatar Mar 27 '19 22:03 krgolovan