Skip to Content
Documentation@blazediff/core

@blazediff/core

High-performance pixel-by-pixel image comparison library. 1.5x faster than pixelmatch  while maintaining identical accuracy.

View Detailed Benchmarks 

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

ParameterTypeDescription
img1Uint8Array | Uint8ClampedArrayImage data of the first image
img2Uint8Array | Uint8ClampedArrayImage data of the second image
outputUint8Array | Uint8ClampedArray | nullOutput buffer for the diff image (optional)
widthnumberWidth of the images in pixels
heightnumberHeight of the images in pixels
optionsBlazeDiffOptionsComparison options (optional)

Options

OptionTypeDefaultDescription
thresholdnumber0.1Matching threshold (0-1). Lower = more sensitive
includeAAbooleanfalseInclude anti-aliased pixels in diff count
alphanumber0.1Opacity 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]nullAlternative color for dark differences
diffMaskbooleanfalseDraw diff as a mask with transparent background
fastBufferCheckbooleantrueUse 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

Last updated on