docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a flexible image comparison system that can compare images with varying levels of sensitivity depending on the comparison context.
Create a module that provides three preset comparison modes for validating images:
Strict Mode: Detect even the smallest pixel differences. This mode should be used for pixel-perfect validation where any difference matters.
Standard Mode: Tolerate minor rendering variations that might occur across different browsers or environments. This is the default mode for typical screenshot testing.
Relaxed Mode: Only flag major differences while ignoring minor color variations. This mode should be used when comparing images that may have slight compression artifacts or minor styling differences.
The system should compare two images and return the number of differing pixels for each mode.
/**
* Compares two images with strict sensitivity (detects smallest differences)
* @param {Buffer|Uint8Array} img1 - First image buffer (RGBA format)
* @param {Buffer|Uint8Array} img2 - Second image buffer (RGBA format)
* @param {number} width - Image width in pixels
* @param {number} height - Image height in pixels
* @returns {number} Number of mismatched pixels
*/
function compareStrict(img1, img2, width, height) {
// IMPLEMENTATION HERE
}
/**
* Compares two images with standard sensitivity (tolerates minor variations)
* @param {Buffer|Uint8Array} img1 - First image buffer (RGBA format)
* @param {Buffer|Uint8Array} img2 - Second image buffer (RGBA format)
* @param {number} width - Image width in pixels
* @param {number} height - Image height in pixels
* @returns {number} Number of mismatched pixels
*/
function compareStandard(img1, img2, width, height) {
// IMPLEMENTATION HERE
}
/**
* Compares two images with relaxed sensitivity (only flags major differences)
* @param {Buffer|Uint8Array} img1 - First image buffer (RGBA format)
* @param {Buffer|Uint8Array} img2 - Second image buffer (RGBA format)
* @param {number} width - Image width in pixels
* @param {number} height - Image height in pixels
* @returns {number} Number of mismatched pixels
*/
function compareRelaxed(img1, img2, width, height) {
// IMPLEMENTATION HERE
}
module.exports = {
compareStrict,
compareStandard,
compareRelaxed,
};Provides pixel-level image comparison capabilities.