Created
January 12, 2015 21:12
-
-
Save cburgmer/87f520a66f083a9deed8 to your computer and use it in GitHub Desktop.
CSS Critic reporter to find offending pixels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
csscritic.addReporter({ | |
reportComparison: function (comparison) { | |
if (imagediff.equal(comparison.pageImage, comparison.referenceImage)) { | |
return; | |
} | |
var d = imagediff.diff(comparison.pageImage, comparison.referenceImage, {align: 'top'}).data; | |
var pixelDiff = [], i; | |
for (i=0; i < d.length; i += 4) { | |
if (d[i] !== 0 || d[i+1] !== 0 || d[i+2] !== 0 || d[i+3] !== 255) { | |
pixelDiff.push([d[i], d[i+1], d[i+2], d[i+3]]); | |
} | |
} | |
console.log(comparison.testCase.url, pixelDiff.length, pixelDiff); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment