createImageBitmap
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.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 50 | 79 | 42 | 15 | 50 | 15 | |
options_colorSpaceConversion_parameter `options.colorSpaceConversion` parameter | 58 | 79 | 98 | 15 | 58 | 15 |
options_imageOrientation_parameter `options.imageOrientation` parameter | 52 | 79 | 93 | 15 | 52 | 15 |
options_imageOrientation_parameter (from-image) Value `from-image` | 112 | 112 | 111 | 16 | 112 | 16 |
options_premultiplyAlpha_parameter `options.premultiplyAlpha` parameter | 52 | 79 | 93 | 17 | 52 | 17 |
options_resizeHeight_parameter `options.resizeHeight` parameter | 54 | 79 | 98 | 15 | 54 | 15 |
options_resizeQuality_parameter `options.resizeQuality` parameter | 54 | 79 | 149 | 15 | 54 | 15 |
options_resizeWidth_parameter `options.resizeWidth` parameter | 54 | 79 | 98 | 15 | 54 | 15 |
svgimageelement_as_source_image `SVGImageElement` as source image | 59 | 79 | 65 | 17.2 | 59 | 17.2 |
| The ImageBitmap interface represents a bitmap image which can be drawn to a canvas without undue latency. It can be created from a variety of source objects using the Window.createImageBitmap() or WorkerGlobalScope.createImageBitmap() factory method. ImageBitmap provides an asynchronous and resource efficient pathway to prepare textures for rendering in… | 50 | 79 | 42 | 15 | 50 | 15 |
| The ImageBitmap.close() method disposes of all graphical resources associated with an ImageBitmap. | 52 | 79 | 46 | 15 | 52 | 15 |
| The ImageBitmap.height read-only property returns the ImageBitmap object's height in CSS pixels. | 50 | 79 | 42 | 15 | 50 | 15 |
| The ImageBitmap.width read-only property returns the ImageBitmap object's width in CSS pixels. | 50 | 79 | 42 | 15 | 50 | 15 |
- This browser only partially implements this feature
- This feature was removed in a later browser version (17)
- If the source image is an `ImageData` object, then the `premultiplyAlpha` option does nothing. See bug 237082.
- This browser only partially implements this feature
- This feature was removed in a later browser version (17)
- If the source image is an `ImageData` object, then the `premultiplyAlpha` option does nothing. See bug 237082.
Syntax
createImageBitmap(image)
createImageBitmap(image, options)
createImageBitmap(image, sx, sy, sw, sh)
createImageBitmap(image, sx, sy, sw, sh, options) Use cases
-
Using createImageBitmap
The createImageBitmap() method of the Window interface creates a bitmap from a given source, optionally cropped to contain only a portion of that source.
Cautions
- May not be supported in older browsers.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.