Read pixels
read_pixelsRead a rectangular region of pixels as structured data, returning distinct colors and an index grid, for computational tasks like sampling palettes or detecting edges.
Instructions
Read a rectangular region as structured data: a list of distinct colours plus a row-major index grid. Use this when you need to compute over pixels (sample a palette from art, find a silhouette edge, copy a region) rather than just look at them. For eyeballing, 'look' is cheaper.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| frame | No | 1-based frame number. Omit to use the active frame. | |
| layer | No | Layer name. Omit to use the active layer. | |
| region | No | Omit to read the whole canvas. | |
| sprite | No | Which sprite: its id as '#7' (what every result reports back, and the only unambiguous form — two unsaved documents are both called 'Sprite'), its filename, or its display name. Omit to use the sprite Aseprite has focused. | |
| composite | No | Read the flattened image. False reads only the target layer's cel. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | ||
| y | Yes | ||
| grid | Yes | Row-major indices into `colors`. | |
| width | Yes | ||
| colors | Yes | Distinct colours; index 0 is fully transparent. | |
| height | Yes | ||
| sprite | Yes | ||
| uniqueColors | Yes |