toDataURL method

String toDataURL([
  1. String type,
  2. JSAny? quality
])

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

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. In other words, if the returned value starts with data:image/png for any other requested type, then that format is not supported.

Browsers are required to support image/png; many will support additional formats including image/jpeg and image/webp.

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

Implementation

external String toDataURL([
  String type,
  JSAny? quality,
]);