get-canvas-pixels

Get an array of RGBA pixel values from a canvas

Usage no npm install needed!

<script type="module">
  import getCanvasPixels from 'https://cdn.skypack.dev/get-canvas-pixels';
</script>

README

get-canvas-pixels

Get an array of RGBA pixel values from a canvas

Extracts an Uint8ClampedArray of RGBA pixel values from a canvas.

Install

$ npm install get-canvas-pixels

Usage

var getCanvasPixels = require('get-canvas-pixels');

var canvas = document.getElementById('canvas');
var pixels = getCanvasPixels(canvas);

console.log(pixels);
/*
[0, 0, 0, 255, 255, 255, 255, 255, ...]
*/