OffscreenCanvas.convertToBlob()

이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 참여해서 번역을 마치도록 도와 주세요!
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.

Syntax

Promise<Blob> OffscreenCanvas.convertToBlob(options);

Parameters

optionsOptional

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 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.

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

Currently drafted as a proposal: OffscreenCanvas.

Browser compatibility

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-dataand send us a pull request.

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

 

See also

 

 

문서 태그 및 공헌자

이 페이지의 공헌자: mdnwebdocs-bot, kebo
최종 변경자: mdnwebdocs-bot,