image2pixels
Opens and converts image to pixels
Install
npm install image2pixels
Usage
Syntax: image2pixels ( imagePath
, [options
], callback
)
Arguments
imagePath
Stringoptions
Object (optional)GD
Boolean (optional) Wether to return a GD obj or raw array. Defaults tofalse
pixelsCallback
Function` (optional) A callback function which receives the raw pixel array before it is returned or processed. Must return the (un)modified array.
callback
Functionerr
- if there was an error otherwise this will be null.output
- node-gd object or array of row objects.
Example
Taken from the example/example.js
var image2pixels = _ = fs = ; // Output first row to json; // Save Image as png; // Recreate the "sorted pixels" effect from node-pixel-sort; { var height = pixelslength width = pixels0length sortedpixels = _ output = forvar i = 0; i < height; i++ output; forvar j = 0; j < width; j++ var pixel = sortedpixelsi*width + j outputi; return output;}