This only works in a modern browser that supports the <canvas> element.