我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译
您也可以阅读此文章的English (US)版。

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

The OffscreenCanvas.convertToBlob() method creates a Blob object representing the image contained in the canvas.


Promise<Blob> OffscreenCanvas.convertToBlob(options);


options Optional

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


  • type: A DOMString 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.

Return value

A Promise returning a Blob object representing the image contained in the canvas.


var offscreen = new OffscreenCanvas(256, 256);
var gl = offscreen.getContext("webgl");

// ... some drawing using the gl context ...

offscreen.convertToBlob().then(function(blob) {

// Blob { size: 334, type: "image/png" }


Currently drafted as a proposal: OffscreenCanvas.

Browser compatibility

No compatibility data found. Please contribute data for "api.OffscreenCanvas.convertToBlob" (depth: 1) to the MDN compatibility data repository.


See also


此页面的贡献者: mdnwebdocs-bot, kebo, some-body, fscholz
最后编辑者: mdnwebdocs-bot,