Save Canvas element to an image

canvas.toDataURL()

generates a data URL of the image, by default a PNG.

// jpeg
canvas.toDataURL("image/jpeg", 1)