4 ms·
So, if I write a script that takes screenshots of my desktop every minute or so, are there any tools out there I could use to “de-dupe” based on some arbitrary
by darkteflon 4y ago
So, if I write a script that takes screenshots of my desktop every minute or so, are there any tools out there I could use to “de-dupe” based on some arbitrary threshold of similarity to existing screenshots? I imagine it would be quite straightforward for identical screenshots, but what about stuff that’s just “mostly unchanged”?
- danhak 4y agoI've had a lot of success using the pixelmatch library for image comparison / deduping https://github.com/mapbox/pixelmatch https://github.com/mapbox/pixelmatch
- darkteflon 4y agoThank you, that looks perfect. > “pixelmatch is around 150 lines of code, has no dependencies…”
- giantrobot 4y ago* Except hundreds of megabytes of Node.js
- augusto-moura 4y agoI imagine that compressing the screenshots daily with something like gzip would do the magic for screenshots. A lot of the image would be repeated anyway, task bar, active windows, background, etc. A good question would be if you screenshot your screen twice in a very small time, how much of the binary would be the same? Are the tools and PNG reproducible enough to dedupe most of the second file on gzip?
- lttlrck 4y agoRecording the whole screen using H.264 or similar at a low frame rate might be easier.
- Ayesh 4y agoA very low tech approach would be to create a video from the screenshots, and let the video codecs do this for you. Av1/x265 are quite mature in detecting differences between frames.
- jefftk 4y agoI agree that's not a bad starting point, but it should be possible to do a lot better than this because a screenshot will often be very similar to an earlier one that's not the previous one. For example, repeatedly switching between a few views. Video codecs are optimized for (a) streams that rarely go back to an earlier pattern, (b) minimal ongoing memory usage, and (c) realtime decompression, so they aren't going for quite the same use case.
- iforgotpassword 4y agoEven h264, which is way over a decade old, can reference frames that are further back than the last one. And it supports lossless. Now the only thing to research is if those two features can be used together and how many frames back it can reference.
- albertzeyer 4y agoSee my other post here: https://news.ycombinator.com/item?id=34566857 https://news.ycombinator.com/item?id=34566857 I wrote a DB for PNG files which deduplicates PNG blocks (only exact matchs): https://github.com/albertz/png-db https://github.com/albertz/png-db