Skip to content

feat: use blazediff to speed up visual diffs#4125

Merged
domoritz merged 2 commits intovega:mainfrom
teimurjan:feat/use-blazediff-instead-of-pixelmatch
Sep 3, 2025
Merged

feat: use blazediff to speed up visual diffs#4125
domoritz merged 2 commits intovega:mainfrom
teimurjan:feat/use-blazediff-instead-of-pixelmatch

Conversation

@teimurjan
Copy link
Contributor

Description

Replace pixelmatch with BlazeDiff. BlazeDiff is 20-25% faster than pixelmatch, using the same API and producing the same results. It weighs 2 times less, is actively supported, and type-safe out of the box.

Benchmarks

Screenshot 2025-09-03 at 15 21 01

@teimurjan teimurjan requested a review from a team as a code owner September 3, 2025 09:21
Copy link
Member

@domoritz domoritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request. I'm usually hesitant to change development dependencies unless there is an issue that they fix but your library looks pretty nice. I'll say though, that I expect you to maintain in over the coming years or we will need to switch back to Pixelmatch.

I was wondering, why don't you upstream your improvements to pixelmatch instead of making a new library? I'm specifically talking about the perf improvements not so much the package setup.

@teimurjan
Copy link
Contributor Author

Hey @domoritz! Thanks for a warm comment.

Yes, I will maintain the current features, add new ones, and work towards library improvements. I have lots of ideas to make it even faster.

I could add my block-based optimization to pixelmatch, but my vision is slightly different.

Firstly, I introduced the concept of transformers, which enable reading and writing images in a format/size/platform. For instance, the next iteration for your package would be trying out @blazediff/bin with @blazediff/sharp-transformer that will theoretically speed it up to 80%.
Secondly, I am going to allow color space customization for the core algorithm. Currently, it uses YIQ (similar to pixelmatch), but I have experimented with YCbCr, which performs better, although the results aren't a direct 1-1 match with pixelmatch. I left this idea on the backlog to avoid breaking changes when migrating from pixelmatch.
Finally, this package will include a WASM-based version written in Rust, which will be dozens of times faster. (here are some experiments: https://github.com/teimurjan/rsdiff)

All these ideas would be too much for pixelmatch, and I assume adding each one would be a very slow process, looking at their response rate for the PRs and issues.

You can rely on my package and my support. I want to grow it :)

@domoritz domoritz merged commit f5c1f43 into vega:main Sep 3, 2025
3 checks passed
@lsh lsh mentioned this pull request Sep 4, 2025
lsh added a commit that referenced this pull request Sep 16, 2025
Changes since v6.1.2

**monorepo**:
* Use blazediff to speed up visual diffs (thanks @teimurjan!) (via
#4125)
* Update version in specs (thanks @domoritz!) (via #4045)

**vega**:
* Export schema from Vega package (thanks @domoritz!) (via #4046)

**vega-loader**:
* Correct mode handling in loader (thanks @domoritz!) (via #4048)

**vega-util**:
* Fix handling of null values in stringValue (thanks @domoritz!) (via
#4127)
* Replace all problematic Unicode characters (thanks @basbroek!) (via
#4130)

**docs**:
* Update links to Prefuse and Protovis (thanks @star1327p!) (via #4095)
* Replace version in specs (thanks @domoritz!) (via #4085)
* Update file name in weather example (thanks @domoritz!) (via #4083)
* Update versions in docs (thanks @domoritz!) (via #4050)
* Update of the labelled donut example (thanks @PBI-David!) (via #4064)
* Addition of the labelled donut example (thanks @PBI-David!) (via
#4062)

---------

Signed-off-by: Lukas Hermann <1734032+lsh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants