I have modified your code to do a few things different.
It speeds it up enormously. I took 6min down to 1sec. I also made it run based on commandline parser so you can now put this on your website or wherever you want. There are a few issues in it if I recall (its been about 6 months since I wrote this). Feel free to tune it up and bring it back for everyone to have. It also uses true luminance vals in algorithm (if wanted).

...