@blazediff/core
High-performance pixel-by-pixel image comparison library. 1.5x faster than pixelmatch while maintaining identical accuracy.
Installation
npm install @blazediff/core
Features
- 1.5x faster than pixelmatch on average
- 88% faster on identical images with early exit optimization
- 100% API compatible with pixelmatch - drop-in replacement
- Zero dependencies - lightweight and efficient
- TypeScript support out of the box
API Reference
blazediff(img1, img2, output, width, height, options?)
Compares two images pixel by pixel and returns the number of different pixels.
Parameters
Parameter | Type | Description |
---|---|---|
img1 | Uint8Array | Uint8ClampedArray | Image data of the first image |
img2 | Uint8Array | Uint8ClampedArray | Image data of the second image |
output | Uint8Array | Uint8ClampedArray | null | Output buffer for the diff image (optional) |
width | number | Width of the images in pixels |
height | number | Height of the images in pixels |
options | BlazeDiffOptions | Comparison options (optional) |
Options
Option | Type | Default | Description |
---|---|---|---|
threshold | number | 0.1 | Matching threshold (0-1). Lower = more sensitive |
includeAA | boolean | false | Include anti-aliased pixels in diff count |
alpha | number | 0.1 | Opacity of original image in diff output |
aaColor | [R,G,B] | [255,255,0] | Color of anti-aliased pixels (yellow) |
diffColor | [R,G,B] | [255,0,0] | Color of different pixels (red) |
diffColorAlt | [R,G,B] | null | Alternative color for dark differences |
diffMask | boolean | false | Draw diff as a mask with transparent background |
fastBufferCheck | boolean | true | Use fast buffer comparison for identical images |
Threshold Guidelines: - 0.0
- Exact match only - 0.05
- Strict
comparison - 0.1
- Default balanced comparison - 0.2
- Lenient comparison
Links
Last updated on