OffscreenCanvas.convertToBlob()

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

OffscreenCanvas.convertToBlob() 메소드는 캔버스에 포함된 이미지를 표현하는 Blob 객체를 생성합니다.

구문

Promise<Blob> OffscreenCanvas.convertToBlob(options);

매개 변수

options Optional

객체를 Blob 객체로 전환할 때 다양한 옵션을 줄 수 있습니다.

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

options:

  • type: 이미지 포맷을 가리키는 DOMString. 상세 타입은 image/png
  • quality: type 옵션이 image/jpeg 혹은 image/webp 일 때 이미지의 품질을 가리키는 01사이의 Number. 이 매개 변수가 다른 값이라면, 이미지 품질의 기본 설정값이 적용됩니다. 다른 매개 변수들은 무시됩니다.

반환 값

캔버스에 포함된 이미지를 표현하는 Blob 객체를 반환하는 Promise

예시

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

// ... gl 컨텍스트를 이용해 무언가를 그립니다 ...

offscreen.convertToBlob().then(function(blob) {
  console.log(blob);
});

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

상세

현재 작성되고 있는 중입니다: OffscreenCanvas.

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
convertToBlob
Experimental
Chrome Full support 69Edge ? Firefox Partial support 46
Notes Alternate Name Disabled
Partial support 46
Notes Alternate Name Disabled
Notes See bug 1390089.
Alternate Name Uses the non-standard name: toBlob
Disabled From version 46: this feature is behind the gfx.offscreencanvas.enabled preference. To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 56Safari No support NoWebView Android No support NoChrome Android Full support 69Firefox Android Partial support 46
Notes Alternate Name Disabled
Partial support 46
Notes Alternate Name Disabled
Notes See bug 1390089.
Alternate Name Uses the non-standard name: toBlob
Disabled From version 46: this feature is behind the gfx.offscreencanvas.enabled preference. To change preferences in Firefox, visit about:config.
Opera Android Full support YesSafari iOS No support NoSamsung Internet Android No support No

Legend

Full support  
Full support
Partial support  
Partial support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.
Uses a non-standard name.
Uses a non-standard name.

 

더 보기