to-image-data
Version:
Convert Nested Numerical Arrays into ImageData Data Array
25 lines (20 loc) • 575 B
Markdown
into [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData/ImageData)
- Handles Numerical Arrays in Any Layout
- Handles Missing Alpha Band
```bash
npm install to-image-data
```
```js
import toImageData from "to-image-data";
const bands = [
[ ], // red
[ ], // green
[ ], // blue
];
const imageData = toImageData(bands);
// { height: 768, width: 1024, data: Uint8ClampedArray[123, 44, 48, 255, 42, 84, 72, 255, ...] }
```
> Convert Nested Numerical Arrays