UNPKG

809 BMarkdownView Raw
1get-pixels
2==========
3Given a URL/path, grab all the pixels in an image and return the result as an [ndarray](https://github.com/mikolalysenko/ndarray). Works both in browserify and in node.js.
4
5**Note** On the node side, currently only supports PNG. Patches welcome!!!
6
7Example
8=======
9
10```javascript
11var getPixels = require("get-pixels")
12
13getPixels("lena.png", function(err, pixels) {
14 if(err) {
15 console.log("Bad image path")
16 return
17 }
18 console.log("got pixels", pixels.shape)
19})
20```
21
22Install
23=======
24
25 npm install get-pixels
26
27### `require("get-pixels")(url, cb(err, pixels))`
28Reads all the pixels from url into an ndarray.
29
30* `url` is the path to the file
31* `cb(err, pixels)` is a callback which gets triggered once the image is loaded.
32
33Credits
34=======
35(c) 2013 Mikola Lysenko. MIT License
\No newline at end of file