Open cburgmer opened 10 years ago
My thoughts: I did want to follow your suggestion and see how things pan out. However, I am not happy with the API. There are a few things:
globalTolerance: true
feels cumbersome.globalTolerance: false
implementation works.Will try to come up with an alternative idea.
Here's my current proposal:
imagediff.equal(a, b, {toleranceValue: 5, toleranceMethod: 'relativePerPixel'});
and
imagediff.equal(a, b, {toleranceValue: 0.25, toleranceMethod: 'totalRatio'});
Can you give me an example of relativePerPixel? Would that be a total difference of 5 across the rgba values for a single pixel?
Sorry for the late response.
relativePerPixel
is the current implementation, where any pixel maybe different as long as it each absolute difference stays below the threshold.
totalRation
is what I'd like to add, where an accumulated difference is used.
I'm not sure about the proposed API anymore though. I think it would be easier if we'd provide a method on it's own for the different tolerances?
This PR tries to solve #18.
As proposed it implements an optional parameter set along the following example:
Following those changes
imagediff.equal(a, b, 128)
would be expressed throughimagediff.equal(a, b, {tolerance: 0.5})
in the future (however the old API remains intact). A global tolerance can be given through addingtotalTolerance: true
to the option object.