Dev.to WebDev 🛠 Dev 👁 0 📖 1 min read

I built a screenshot diff tool and found a nasty Canvas bug

I built a small open-source tool called Visual Diff Studio for comparing screenshots. The idea is simple: drop in two screenshots, see what changed, and export the result for a GitHub pull request. It has three compari

I built a small open-source tool called Visual Diff Studio for comparing screenshots.

The idea is simple: drop in two screenshots, see what changed, and export the result for a GitHub pull request.

It has three comparison modes: a before/after slider, side-by-side view, and pixel diff. You can also compare batches of screenshots and export an offline HTML report.

Everything runs in your browser. No accounts, no server uploads.

A bug I didn't expect

During testing, we found something pretty nasty.

Two completely different PNGs: one black, one white, both 1x70,000 pixels - were reported as 0% different.

The original implementation limited images by total pixel count, but that wasn't enough. Chrome's Canvas returned empty pixel data for those dimensions.

We fixed it by adding limits for each image dimension, not just the total area. Unsupported images now produce an error instead of a misleading comparison.

That was a good reminder that passing tests doesn't always mean your results are correct.

Try it

Live demo: https://ruslanty.github.io/visual-diff-studio/

GitHub: https://github.com/ruslanty/visual-diff-studio

It's free, MIT-licensed, and there's a built-in example if you just want to play with it.

I'm curious how other developers handle screenshot comparisons during code reviews.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.