toBlob

suspend fun HTMLCanvasElement.toBlob(type: String): Blob?(source)
suspend fun HTMLCanvasElement.toBlob(type: String, quality: Double): Blob?(source)

The HTMLCanvasElement.toBlob() method creates a Blob object representing the image contained in the canvas. This file may be cached on the disk or stored in memory at the discretion of the user agent.

MDN Reference