Skip to content

sdtm1016/blazediff

 
 

Repository files navigation

BlazeDiff

License: MIT NPM Version BenchmarkAsk DeepWiki

BlazeDiff — a high-performance, pixel-perfect image comparison library for JavaScript. 1.5x faster than pixelmatch, with identical accuracy and output quality. It uses an innovative block-based algorithm to achieve blazing-fast pixel-by-pixel image diffing. Built on the foundation of pixelmatch but with significant optimizations, it's designed for visual testing, CI/CD pipelines, and any application requiring fast, accurate image comparison.

100% API and Result Compatible: BlazeDiff is fully compatible with pixelmatch's API and produces identical results when using the YIQ color space flag.

Features

BlazeDiff is 1.5x faster than pixelmatch while maintaining the same accuracy and output quality. The performance improvement comes from:

  • Block-based algorithm: First pass creates dynamic-sized blocks and only processes changed blocks
  • Early exit optimization: Returns immediately if no buffer differences are detected (Native C++ in Node)
  • 32-bit integer comparisons: Leverages CPU vectorization for faster pixel matching
  • JPEG and WebP support: When using the binary with the Sharp transformer, BlazeDiff supports PNG, JPEG and WebP inputs.
Expected Actual Diff
Expected Expected Expected

Use Cases

BlazeDiff is available in multiple packages to suit different use cases:

Benchmarks

Algorithm (@blazediff/core vs pixelmatch)

50 iterations (3 warmup)

~50% performance improvement on average.

Benchmark Pixelmatch BlazeDiff Time Saved % Improvement
4k/1 294.86ms 274.29ms 20.57ms 7.0%
4k/1 (identical) 19.74ms 2.33ms 17.41ms 88.2%
4k/2 295.46ms 274.97ms 20.49ms 6.9%
4k/2 (identical) 22.10ms 2.59ms 19.51ms 88.3%
4k/3 373.39ms 344.06ms 29.32ms 7.9%
4k/3 (identical) 26.61ms 3.11ms 23.51ms 88.3%
page/1 321.33ms 92.50ms 228.83ms 71.2%
page/1 (identical) 66.57ms 7.66ms 58.91ms 88.5%
page/2 418.13ms 375.39ms 42.75ms 10.2%
page/2 (identical) 45.99ms 5.42ms 40.57ms 88.2%
pixelmatch/1 0.86ms 0.52ms 0.34ms 39.7%
pixelmatch/1 (identical) 0.15ms 0.01ms 0.13ms 90.5%
pixelmatch/2 2.08ms 2.01ms 0.07ms 3.4%
pixelmatch/2 (identical) 0.07ms 0.01ms 0.07ms 89.8%
pixelmatch/3 0.77ms 0.31ms 0.46ms 59.6%
pixelmatch/3 (identical) 0.15ms 0.01ms 0.13ms 90.5%
pixelmatch/4 4.15ms 3.93ms 0.22ms 5.3%
pixelmatch/4 (identical) 0.20ms 0.02ms 0.18ms 90.7%
pixelmatch/5 0.24ms 0.14ms 0.11ms 43.6%
pixelmatch/5 (identical) 0.07ms 0.01ms 0.06ms 89.1%
pixelmatch/6 0.92ms 0.89ms 0.03ms 2.9%
pixelmatch/6 (identical) 0.07ms 0.01ms 0.06ms 90.1%
pixelmatch/7 1.90ms 1.35ms 0.55ms 29.1%
pixelmatch/7 (identical) 0.28ms 0.03ms 0.25ms 90.6%

Benchmarks run on MacBook Pro M1 Max, Node.js 22

Binary (@blazediff/bin with @blazediff/sharp-transformer)

50 iterations (3 warmup)

~60% performance improvement on average.

Benchmark Pixelmatch BlazeDiff Time Saved % Improvement
4k/1 1832.83ms 818.00ms 1014.84ms 55.4%
4k/1 (identical) 1480.47ms 499.92ms 980.55ms 66.2%
4k/2 1927.86ms 856.67ms 1071.18ms 55.6%
4k/2 (identical) 1589.19ms 565.47ms 1023.72ms 64.4%
4k/3 2071.07ms 927.41ms 1143.66ms 55.2%
4k/3 (identical) 1707.19ms 574.57ms 1132.62ms 66.3%
page/1 2420.72ms 737.27ms 1683.44ms 69.5%
page/1 (identical) 2169.74ms 547.40ms 1622.34ms 74.8%
page/2 1866.68ms 750.66ms 1116.02ms 59.8%
page/2 (identical) 1490.23ms 362.18ms 1128.05ms 75.7%

Benchmarks run on MacBook Pro M1 Max, Node.js 22

Benchmarks in GitHub Actions

benchmark.yml

Contributing

Contributions are welcome! Please see the Contributing Guide for details.

License

MIT License - see LICENSE file for details.

Acknowledgments


Built for high-performance image comparison

About

Blazing-fast pixel-by-pixel image comparison with block-based optimization. 1.5x times faster than pixelmatch.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 82.8%
  • JavaScript 16.9%
  • HTML 0.3%