Window: createImageBitmap() method

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.

* Some parts of this feature may have varying levels of support.

The createImageBitmap() method of the Window interface creates a bitmap from a given source, optionally cropped to contain only a portion of that source. It accepts a variety of different image sources, and returns a Promise which resolves to an ImageBitmap.

Syntax

js
createImageBitmap(image)
createImageBitmap(image, options)
createImageBitmap(image, sx, sy, sw, sh)
createImageBitmap(image, sx, sy, sw, sh, options)

Parameters

image

An image source, which can be any one of the following:

sx

The x coordinate of the reference point of the rectangle from which the ImageBitmap will be extracted.

sy

The y coordinate of the reference point of the rectangle from which the ImageBitmap will be extracted.

sw

The width of the rectangle from which the ImageBitmap will be extracted. This value can be negative.

sh

The height of the rectangle from which the ImageBitmap will be extracted. This value can be negative.

options Optional

An object that sets options for the image's extraction. The available options are:

imageOrientation

Specifies how the bitmap image should be oriented.

from-image

Image oriented according to EXIF orientation metadata, if present (default).

flipY

Image oriented according to EXIF orientation metadata, if present, and then flipped vertically.

none

Image oriented according to image encoding, ignoring any metadata about the orientation (such as EXIF metadata, that might be added to an image to indicate that the camera was turned sideways to capture the image in portrait mode).

premultiplyAlpha

Specifies whether the bitmap's color channels should be premultiplied by the alpha channel. One of none, premultiply, or default (default).

colorSpaceConversion

Specifies whether the image should be decoded using color space conversion. Either none or default (default). The value default indicates that implementation-specific behavior is used.

resizeWidth

A long integer that indicates the output width.

resizeHeight

A long integer that indicates the output height.

resizeQuality

Specifies the algorithm to be used for resizing the input to match the output dimensions. One of pixelated, low (default), medium, or high.

Return value

A Promise which resolves to an ImageBitmap object containing bitmap data from the given rectangle.

Examples

Creating sprites from a sprite sheet

This example loads a sprite sheet, extracts individual sprites, and then renders each sprite to the canvas. A sprite sheet is an image containing multiple smaller images, each of which you want to be able to render separately.

js
const canvas = document.getElementById("myCanvas"),
  ctx = canvas.getContext("2d"),
  image = new Image();

// Wait for the sprite sheet to load
image.onload = () => {
  Promise.all([
    // Cut out two sprites from the sprite sheet
    createImageBitmap(image, 0, 0, 32, 32),
    createImageBitmap(image, 32, 0, 32, 32),
    createImageBitmap(image, 0, 0, 50, 50, { imageOrientation: "flipY" }),
  ]).then((sprites) => {
    // Draw each sprite onto the canvas
    ctx.drawImage(sprites[0], 0, 0);
    ctx.drawImage(sprites[1], 32, 32);
    ctx.drawImage(sprites[2], 64, 64);
  });
};

// Load the sprite sheet from an image file
image.src = "50x50.jpg";

Specifications

Specification
HTML
# dom-createimagebitmap-dev

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
createImageBitmap
Chrome – Full support
Chrome 50 (Release date: 2016-04-13)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 42 (Release date: 2015-11-03)
footnote Full support
Opera – Full support
Opera 37 (Release date: 2016-05-04)
footnote Full support
Safari – Full support
Safari 15 (Release date: 2021-09-20)
footnote
footnote See bug 182424
Chrome Android – Full support
Chrome Android 50 (Release date: 2016-04-13)
footnote Full support
Firefox for Android – Full support
Firefox for Android 42 (Release date: 2015-11-03)
footnote Full support
Opera Android – Full support
Opera Android 37 (Release date: 2016-06-16)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote
footnote See bug 182424
Samsung Internet – Full support
Samsung Internet 5 (Release date: 2016-12-15)
footnote Full support
WebView Android – Full support
WebView Android 50 (Release date: 2016-04-13)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15 (Release date: 2021-09-20)
footnote
footnote See bug 182424
Deno – Full support
Deno 1.40 (Release date: 2024-01-25)
footnote Full support
options.colorSpaceConversion parameter
Chrome – Full support
Chrome 58 (Release date: 2017-04-19)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 98 (Release date: 2022-03-08)
footnote Full support
Opera – Full support
Opera 45 (Release date: 2017-05-10)
footnote Full support
Safari – Full support
Safari 15 (Release date: 2021-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 58 (Release date: 2017-04-25)
footnote Full support
Firefox for Android – Full support
Firefox for Android 98 (Release date: 2022-03-08)
footnote Full support
Opera Android – Full support
Opera Android 43 (Release date: 2017-09-27)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
Samsung Internet – Full support
Samsung Internet 7 (Release date: 2018-03-16)
footnote Full support
WebView Android – Full support
WebView Android 58 (Release date: 2017-04-25)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15 (Release date: 2021-09-20)
footnote Full support
Deno – Full support
Deno 2.2 (Release date: 2025-02-19)
footnote Full support
options.imageOrientation parameter
Chrome – Full support
Chrome 52 (Release date: 2016-07-20)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 93 (Release date: 2021-10-05)
footnote Full support
Opera – Full support
Opera 39 (Release date: 2016-08-02)
footnote Full support
Safari – Full support
Safari 15 (Release date: 2021-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 52 (Release date: 2016-07-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 93 (Release date: 2021-10-05)
footnote Full support
Opera Android – Full support
Opera Android 41 (Release date: 2016-10-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
Samsung Internet – Full support
Samsung Internet 6 (Release date: 2017-08-23)
footnote Full support
WebView Android – Full support
WebView Android 52 (Release date: 2016-07-27)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15 (Release date: 2021-09-20)
footnote Full support
Deno – Full support
Deno 1.40 (Release date: 2024-01-25)
footnote Full support
Value from-image
Chrome – Full support
Chrome 112 (Release date: 2023-04-04)
footnote Full support
Edge – Full support
Edge 112 (Release date: 2023-04-06)
footnote Full support
Firefox – Full support
Firefox 111 (Release date: 2023-03-14)
footnote Full support
Opera – Full support
Opera 98 (Release date: 2023-04-20)
footnote Full support
Safari – Full support
Safari 16 (Release date: 2022-09-12)
footnote Full support
Chrome Android – Full support
Chrome Android 112 (Release date: 2023-04-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 111 (Release date: 2023-03-14)
footnote Full support
Opera Android – Full support
Opera Android 75 (Release date: 2023-05-17)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16 (Release date: 2022-09-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 23 (Release date: 2023-10-18)
footnote Full support
WebView Android – Full support
WebView Android 112 (Release date: 2023-04-04)
footnote Full support
WebView on iOS – Full support
WebView on iOS 16 (Release date: 2022-09-12)
footnote Full support
Deno – Full support
Deno 1.40 (Release date: 2024-01-25)
footnote Full support
Value none
Experimental Non-standard
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote No support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – Full support
Deno 1.40 (Release date: 2024-01-25)
footnote Full support
options.premultiplyAlpha parameter
Chrome – Full support
Chrome 52 (Release date: 2016-07-20)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 93 (Release date: 2021-10-05)
footnote Full support
Opera – Full support
Opera 39 (Release date: 2016-08-02)
footnote Full support
Safari – Partial support
Safari 15 – 16.6 (Release date: 2021-09-20)
footnote Partial support
footnote If the source image is an ImageData object, then the premultiplyAlpha option does nothing. See bug 237082.
Safari – Full support
Safari 17 (Release date: 2023-09-18)
footnote Full support
Chrome Android – Full support
Chrome Android 52 (Release date: 2016-07-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 93 (Release date: 2021-10-05)
footnote Full support
Opera Android – Full support
Opera Android 41 (Release date: 2016-10-25)
footnote Full support
Safari on iOS – Partial support
Safari on iOS 15 – 16.6 (Release date: 2021-09-20)
footnote Partial support
footnote If the source image is an ImageData object, then the premultiplyAlpha option does nothing. See bug 237082.
Safari on iOS – Full support
Safari on iOS 17 (Release date: 2023-09-18)
footnote Full support
Samsung Internet – Full support
Samsung Internet 6 (Release date: 2017-08-23)
footnote Full support
WebView Android – Full support
WebView Android 52 (Release date: 2016-07-27)
footnote Full support
WebView on iOS – Partial support
WebView on iOS 15 – 16.6 (Release date: 2021-09-20)
footnote Partial support
footnote If the source image is an ImageData object, then the premultiplyAlpha option does nothing. See bug 237082.
WebView on iOS – Full support
WebView on iOS 17 (Release date: 2023-09-18)
footnote Full support
Deno – Full support
Deno 1.40 (Release date: 2024-01-25)
footnote Full support
options.resizeHeight parameter
Chrome – Full support
Chrome 54 (Release date: 2016-10-12)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 98 (Release date: 2022-03-08)
footnote Full support
Opera – Full support
Opera 41 (Release date: 2016-10-25)
footnote Full support
Safari – Full support
Safari 15 (Release date: 2021-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 54 (Release date: 2016-10-19)
footnote Full support
Firefox for Android – Full support
Firefox for Android 98 (Release date: 2022-03-08)
footnote Full support
Opera Android – Full support
Opera Android 41 (Release date: 2016-10-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
Samsung Internet – Full support
Samsung Internet 6 (Release date: 2017-08-23)
footnote Full support
WebView Android – Full support
WebView Android 54 (Release date: 2016-10-19)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15 (Release date: 2021-09-20)
footnote Full support
Deno – Full support
Deno 1.40 (Release date: 2024-01-25)
footnote Full support
options.resizeQuality parameter
Chrome – Full support
Chrome 54 (Release date: 2016-10-12)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 149 (Release date: 2026-03-24)
footnote Full support
Opera – Full support
Opera 41 (Release date: 2016-10-25)
footnote Full support
Safari – Full support
Safari 15 (Release date: 2021-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 54 (Release date: 2016-10-19)
footnote Full support
Firefox for Android – Full support
Firefox for Android 149 (Release date: 2026-03-24)
footnote Full support
Opera Android – Full support
Opera Android 41 (Release date: 2016-10-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
Samsung Internet – Full support
Samsung Internet 6 (Release date: 2017-08-23)
footnote Full support
WebView Android – Full support
WebView Android 54 (Release date: 2016-10-19)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15 (Release date: 2021-09-20)
footnote Full support
Deno – Full support
Deno 1.40 (Release date: 2024-01-25)
footnote Full support
options.resizeWidth parameter
Chrome – Full support
Chrome 54 (Release date: 2016-10-12)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 98 (Release date: 2022-03-08)
footnote Full support
Opera – Full support
Opera 41 (Release date: 2016-10-25)
footnote Full support
Safari – Full support
Safari 15 (Release date: 2021-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 54 (Release date: 2016-10-19)
footnote Full support
Firefox for Android – Full support
Firefox for Android 98 (Release date: 2022-03-08)
footnote Full support
Opera Android – Full support
Opera Android 41 (Release date: 2016-10-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
Samsung Internet – Full support
Samsung Internet 6 (Release date: 2017-08-23)
footnote Full support
WebView Android – Full support
WebView Android 54 (Release date: 2016-10-19)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15 (Release date: 2021-09-20)
footnote Full support
Deno – Full support
Deno 1.40 (Release date: 2024-01-25)
footnote Full support
SVGImageElement as source image
Chrome – Full support
Chrome 59 (Release date: 2017-06-05)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 65 (Release date: 2019-01-29)
footnote Full support
Opera – Full support
Opera 46 (Release date: 2017-06-22)
footnote Full support
Safari – Full support
Safari 17.2 (Release date: 2023-12-11)
footnote Full support
Chrome Android – Full support
Chrome Android 59 (Release date: 2017-06-06)
footnote Full support
Firefox for Android – Full support
Firefox for Android 65 (Release date: 2019-01-29)
footnote Full support
Opera Android – Full support
Opera Android 43 (Release date: 2017-09-27)
footnote Full support
Safari on iOS – Full support
Safari on iOS 17.2 (Release date: 2023-12-11)
footnote Full support
Samsung Internet – Full support
Samsung Internet 7 (Release date: 2018-03-16)
footnote Full support
WebView Android – Full support
WebView Android 59 (Release date: 2017-06-06)
footnote Full support
WebView on iOS – Full support
WebView on iOS 17.2 (Release date: 2023-12-11)
footnote Full support
Deno – No support
Deno
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Experimental. Expect behavior to change in the future.
Non-standard. Check cross-browser support before using.
See implementation notes.
Has more compatibility info.

See also