### Install Dependencies and Build Project Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Install project dependencies using pnpm and build the release version of the Rust project using Cargo. ```bash pnpm install cargo build --release ``` -------------------------------- ### Install Honeydiff Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Install the honeydiff package using npm. Requires Node.js 22 or higher. ```bash npm install @vizzly-testing/honeydiff ``` -------------------------------- ### Run Project Tests Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Execute the test suite for the Honeydiff project using Cargo. ```bash cargo test ``` -------------------------------- ### Detailed Image Comparison with Options Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Use the compare function for detailed image comparison, allowing configuration of diff output paths, threshold, cluster analysis, and overwrite behavior. ```javascript let result = await compare('baseline.png', 'current.png', { threshold: 2.0, includeClusters: true, diffPath: 'artifacts/diff.png', maskPath: 'artifacts/mask.png', overlayPath: 'artifacts/overlay.png', overwrite: true, }); console.log(result.isDifferent); console.log(result.diffPercentage); console.log(result.diffClusters); ``` -------------------------------- ### Import Honeydiff API Functions Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Import all available functions from the Honeydiff library for use in your project. This includes functions for WCAG analysis, image comparison, fingerprinting, and metadata retrieval. ```javascript import { analyzeWcagAllCvd, analyzeWcagContrast, analyzeWcagForCvd, compare, compareSync, computeFingerprintSync, fingerprintHashSync, fingerprintSimilaritySync, getColorBlindnessTypes, getDimensions, getDimensionsSync, getImageMetadata, getImageMetadataFromFile, getImageMetadataFromFileSync, getImageMetadataSync, quickCompare, quickCompareSync, saveAllColorBlindnessSimulations, saveColorBlindnessSimulation, saveWcagOverlay, simulateColorBlindness, } from '@vizzly-testing/honeydiff'; ``` -------------------------------- ### Quick Image Comparison Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Use quickCompare for a simple boolean check if two images differ. This is useful for basic visual regression checks. ```javascript import { compare, quickCompare } from '@vizzly-testing/honeydiff'; let changed = await quickCompare('baseline.png', 'current.png'); if (changed) { console.log('Visual change detected'); } ``` -------------------------------- ### Migration from v0.4.x to v0.5.0 for Image Comparison Source: https://github.com/vizzly-testing/honeydiff/blob/main/CHANGELOG.md Illustrates the API changes when migrating from older versions to v0.5.0, specifically the removal of old tolerance options and the addition of the new CIEDE2000-based 'threshold' option. ```typescript const result = await compare('baseline.png', 'current.png', { pixelTolerance: 10, colorThreshold: 0.1, ignoreColors: false }); ``` ```typescript const result = await compare('baseline.png', 'current.png', { threshold: 2.0 }); ``` -------------------------------- ### Add Perceptual Metrics to Comparison Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Enhances image comparison by including advanced perceptual metrics such as SSIM (Structural Similarity Index Measure) and GMSD (Gradient Magnitude Similarity Difference). ```javascript import { compare } from '@vizzly-testing/honeydiff'; let result = await compare('baseline.png', 'current.png', { includeSSIM: true, includeGMSD: true, }); console.log(result.perceptualScore); console.log(result.gmsdScore); ``` -------------------------------- ### Compare Images Using Buffers Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Compares two images provided as Node.js Buffers. This is useful when images are read from memory or network streams instead of directly from files. ```javascript import { readFile } from 'node:fs/promises'; import { compare } from '@vizzly-testing/honeydiff'; let baseline = await readFile('baseline.png'); let current = await readFile('current.png'); let result = await compare(baseline, current); ``` -------------------------------- ### Generate Review Artifacts Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Compares two images and generates artifact files for visual debugging, including a diff image, a mask image, and an overlay image. The `overwrite: true` option ensures existing artifact files are replaced. ```javascript import { compare } from '@vizzly-testing/honeydiff'; let result = await compare('baseline.png', 'current.png', { diffPath: 'artifacts/diff.png', maskPath: 'artifacts/mask.png', overlayPath: 'artifacts/overlay.png', overwrite: true, }); ``` -------------------------------- ### Compare Two Images with Threshold Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Compares two image files and returns a result object indicating if they are different and the percentage of changed pixels. Uses CIEDE2000 perceptual color difference with a default threshold of 2.0. ```javascript import { compare } from '@vizzly-testing/honeydiff'; let result = await compare('before.png', 'after.png', { threshold: 2.0, }); if (result.isDifferent) { console.log(`${result.diffPercentage.toFixed(2)}% of pixels changed`); } ``` -------------------------------- ### Analyze Screenshot Contrast Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Analyzes a screenshot image for WCAG contrast violations. It provides a report detailing the number of violations, pass percentages for different contrast levels, and a list of specific violations. ```javascript import { analyzeWcagContrast } from '@vizzly-testing/honeydiff'; let report = await analyzeWcagContrast('screenshot.png'); console.log(report.violations.length); console.log(report.aaNormalPassPercentage); console.log(report.violations); ``` -------------------------------- ### Simulate Color Vision Deficiency Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Generates a simulated version of a screenshot as perceived by individuals with specific types of color vision deficiency (e.g., deuteranopia). The simulated image is saved to a specified file path. ```javascript import { saveColorBlindnessSimulation, } from '@vizzly-testing/honeydiff'; await saveColorBlindnessSimulation( 'screenshot.png', 'deuteranopia', 'screenshot-deuteranopia.png' ); ``` -------------------------------- ### Group Differences into Regions Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Compares images and identifies spatial clusters of differences. Options like `includeClusters`, `minClusterSize`, and `clusterMerge` control the detection and merging of these clusters. ```javascript import { compare } from '@vizzly-testing/honeydiff'; let result = await compare('baseline.png', 'current.png', { includeClusters: true, minClusterSize: 2, clusterMerge: true, }); for (let cluster of result.diffClusters ?? []) { console.log(cluster.pixelCount, cluster.boundingBox); } ``` -------------------------------- ### Honeydiff DiffResult Interface Source: https://github.com/vizzly-testing/honeydiff/blob/main/README.md Defines the structure of the result returned by Honeydiff, including difference metrics, pixel counts, bounding boxes, and optional detailed lists of differing pixels or clusters. ```typescript interface DiffResult { isDifferent: boolean; diffPercentage: number; totalPixels: number; diffPixels: number; aaPixelsIgnored: number; aaPercentage: number; boundingBox: BoundingBox | null; heightDiff: HeightDiff | null; diffPixelsList: DiffPixel[] | null; diffClusters: DiffCluster[] | null; intensityStats: IntensityStats | null; perceptualScore: number | null; gmsdScore: number | null; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.