---
title: getImageData
framework: webkitjs
role: symbol
role_heading: Instance Method
path: webkitjs/canvasrenderingcontext2d/1632656-getimagedata
---

# getImageData

Gets an imageData object containing an RGBa pixel array corresponding to a rectangular area of the canvas.

## Declaration

```data
ImageData getImageData(
    float sx, 
    float sy, 
    float sw, 
    float sh
);
```

## Parameters

- `sx`: The x-coordinate of the left edge of the rectangle.
- `sy`: The y-coordinate of the top of the rectangle.
- `sw`: The width of the rectangle.
- `sh`: The height of the rectangle.

## Return Value

Return Value An imageData object.

## Discussion

Discussion All parameter values are in pixels relative to the upper-left corner of the canvas, not the current canvas coordinate system. The returned imageData object has two read-only properties: width and height. The imageData object’s data property is a one-dimensional array of RGBa pixel values in row order from left to right, with four values for each pixel—red, green, blue, and alpha. The RGBa values are integers with a range of 0-255, inclusive.

## See Also

### Manipulating Pixels

- [createImageData](webkitjs/canvasrenderingcontext2d/1632980-createimagedata.md)
- [putImageData](webkitjs/canvasrenderingcontext2d/1633082-putimagedata.md)
