W3cubDocs

/Web APIs

ImageData

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

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

Note: This feature is available in Web Workers.

The ImageData interface represents the underlying pixel data of an area of a <canvas> element.

It is created using the ImageData() constructor or creator methods on the CanvasRenderingContext2D object associated with a canvas: createImageData() and getImageData(). It can also be used to set a part of the canvas by using putImageData().

Constructors

ImageData()

Creates an ImageData object from a given Uint8ClampedArray or Float16Array and the size of the image it contains. If no array is given, it creates an image of a transparent black rectangle. Note that this is the most common way to create such an object in workers as createImageData() is not available there.

Instance properties

ImageData.data Read only

A Uint8ClampedArray or Float16Array representing a one-dimensional array containing the data in the RGBA order. The order goes by rows from the top-left pixel to the bottom-right.

ImageData.colorSpace Read only

A string indicating the color space of the image data.

ImageData.height Read only

An unsigned long representing the actual height, in pixels, of the ImageData.

ImageData.width Read only

An unsigned long representing the actual width, in pixels, of the ImageData.

ImageData.pixelFormat Read only Experimental

A string indicating the format to use for the ImageData.

Specifications

Specification
HTML>
# imagedata>

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
ImageData 36 14 29 23 8 36 29 24 8 3.0 37 8
ImageData 1 12 3.5 9 3.1 18 4 10.1 2 1.0 4.4 2
colorSpace 92 92 No 78 15.2 92 No 65 15.2 16.0 92 15.2
data 1 12 3.5 9 3.1 18 4 10.1 2 1.0 4.4 2
height 1 12 3.5 9 3.1 18 4 10.1 2 1.0 4.4 2
pixelFormat 137 137 No 121 No 137 No 90 No No 137 No
width 1 12 3.5 9 3.1 18 4 10.1 2 1.0 4.4 2
worker_support 36 14 25 23 7 36 25 24 7 3.0 37 7

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ImageData