This was the result of trying to use pHash in a project and getting increasingly pissed off at CImg. What kind of an asshole distributes a single 3+ MiB C++ header?
I'm quite satisfied with the result. My implementation is not only hundreds of times smaller, but also four times faster, and compatible with pHash.