JavaScript: image average color