Allocate transparent-black pixels of the given size.
Optionalsettings: ImageDataSettingsWrap an existing buffer. Its length must match the dimensions at the chosen ImageDataSettings.colorType, or the call throws; the height may be left out and is then derived from the length.
Optionalsh: numberOptionalsettings: ImageDataSettingsCopy a decoded Image into pixel data. An overload this library adds; a browser has no constructor taking an image.
Optionalsettings: ImageDataSettingsReadonlybytesBytes each pixel occupies under ImageData.colorType. The only way
to walk data correctly for a non-rgba format.
🧪 Not in the HTML Canvas standard.
ReadonlycolorColor space the components are in. Unlike a browser's, which only ever
reports "srgb" or "display-p3", this carries whichever
ColorSpace the data was read in.
Readonlycolor🧪 Not in the HTML Canvas standard.
ReadonlydataThe pixels themselves, row by row from the top left.
Typed as Uint8ClampedArray for compatibility, and it is one for the
eight-bit formats. For a float ImageData.colorType the same
bytes are the encoding of wider components, so walk them by
ImageData.bytesPerPixel rather than four at a time.
ReadonlyheightNumber of rows.
The prototype every instance inherits from.
ReadonlywidthNumber of pixels per row.
Copy the pixels into a Sharp image. Sharp is an optional peer dependency and must be installed separately.
🧪 Not in the HTML Canvas standard.
A rectangle of raw pixel data, as CanvasRenderingContext2D.getImageData returns and CanvasRenderingContext2D.putImageData takes.
MDN Reference