toBlob method

void toBlob(
  1. BlobCallback callback, [
  2. String type,
  3. JSAny? quality
])

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.

The desired file format and image quality may be specified. If the file format is not specified, or if the given format is not supported, then the data will be exported as image/png. Browsers are required to support image/png; many will support additional formats including image/jpeg and image/webp.

The created image will have a resolution of 96dpi for file formats that support encoding resolution metadata.

Implementation

external void toBlob(
  BlobCallback callback, [
  String type,
  JSAny? quality,
]);