Modified to take an object which allows you to specify a callback instead of assuming an image.
Optimisation for window metrics.
Merge pull request #1 from pgaske/master

Modified to use a callback mechanism.  Backward compatible usage.