Skip to content

Canvas.toDataURL ​

JS
    string Canvas.toDataURL(string type, string encoderOptions)

Returns a string in data URI format.

If the canvas height or width is 0, the string "data:," is returned.

If the passed type is not "image/png" but the returned value starts with "data:image/png", then the passed type is not supported.

Parameters

  • string type: [Optional] Image format, defaults to image/png

  • string encoderOptions: [Optional] When the image format is specified as image/jpeg, you can select the image quality within the range 0 to 1. If out of range, the default value 0.92 is used. Other parameters are ignored.

Return Value

  • string: Returns a string in data URI format