The HTMLCanvasElement.toDataURL() method returns a data URL containing a representation of the image in the format specified by the type parameter.
HTMLCanvasElement.toDataURL()
type
MDN Reference