Skip to content

Instantly share code, notes, and snippets.

@cburgmer
Created January 12, 2015 21:12
Show Gist options
  • Save cburgmer/87f520a66f083a9deed8 to your computer and use it in GitHub Desktop.
Save cburgmer/87f520a66f083a9deed8 to your computer and use it in GitHub Desktop.
CSS Critic reporter to find offending pixels
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