AwaitedDOM/ OffscreenCanvas

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Properties

.height
W3C

The height of the offscreen canvas.

Type: Promise<number>

.width
W3C

The width of the offscreen canvas.

Type: Promise<number>

Methods

.convertToBlob(options?)
W3C

Creates a Blob object representing the image contained in the canvas.

Arguments:

  • options ImageEncodeOptions.

    You can specify several options when converting your OffscreenCanvas object into a Blob object, for example:

    const blob = offscreenCanvas.convertToBlob({
       type: "image/jpeg",
       quality: 0.95
     });

    options:

    • **type**: A `string` indicating the image format. The default type is image/png.
    • **quality**: A `number` between 0 and 1 indicating image quality if the type option is image/jpeg or image/webp. If this argument is anything else, the default value for image quality is used. Other arguments are ignored.

Returns: Promise<Blob>

.transferToImageBitmap()
W3C

Creates an ImageBitmap object from the most recently rendered image of the OffscreenCanvas.

Returns: ImageBitmap

Unimplemented Specs

Methods

getContext()addEventListener()
dispatchEvent()removeEventListener()

Edit this page on GitHub