OffscreenCanvas.convertToBlob()
Experimental: 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.
Syntax
Promise<Blob> OffscreenCanvas.convertToBlob(options);
Parameters
-
optionsOptional -
You can specify several options when converting your
OffscreenCanvasobject into aBlobobject, for example:const blob = offscreenCanvas.convertToBlob({ type: "image/jpeg", quality: 0.95 });options:
Return value
A Promise returning a Blob object representing the image contained in the canvas.
Examples
var offscreen = new OffscreenCanvas(256, 256);
var gl = offscreen.getContext("webgl");
// ... some drawing using the gl context ...
offscreen.convertToBlob().then(function(blob) {
console.log(blob);
});
// Blob { size: 334, type: "image/png" }
Specifications
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
convertToBlob |
69 |
79 |
46
See bug 1390089.
|
No |
56 |
No |
No |
69 |
46
See bug 1390089.
|
48 |
No |
10.0 |
See also
- The interface defining this method,
OffscreenCanvas.
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/convertToBlob