W3cubDocs

/DOM

ImageData

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 and the size of the image it contains. If no array is given, it creates an image of a black rectangle. Note that this is the most common way to create such an object in workers as createImageData() is not available there.

Properties

ImageData.data Read only
Is a Uint8ClampedArray representing a one-dimensional array containing the data in the RGBA order, with integer values between 0 and 255 (included).
ImageData.height Read only
Is an unsigned long representing the actual height, in pixels, of the ImageData.
ImageData.width Read only
Is an unsigned long representing the actual width, in pixels, of the ImageData.

Specifications

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 4 Yes 14 9 9 3.1
Available in workers Yes ? 25 ? ? ?
ImageData() constructor 42 Yes 29 No 29 ?
data Yes 12 14 9 9 3.1
height Yes 12 14 9 9 3.1
width Yes 12 14 9 9 3.1
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support Yes Yes ? 14 10 3.2 Yes
Available in workers Yes ? ? 25 ? ? ?
ImageData() constructor No 42 ? 29 ? ? 4.0
data ? Yes Yes 14 Yes Yes Yes
height Yes Yes Yes 14 Yes Yes Yes
width Yes Yes Yes 14 Yes Yes Yes

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ImageData