looks-same
looks-same copied to clipboard
Feature: ignore rectangle
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?
Similarly, I'd love to have a whitelist of comparison zones too!
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? ;)
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
// ]
// }
});
To my mind it's not the best solution. It would be much better if looks-same provided API to ignore some areas.
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.