pixels
Pixels is a minimal image processing library written in JavaScript.
$ npm install pixels$ npm test
var px = ;
Currently supports read/write for PNG and JPEG.
Usage
Read image into a Float64Array
.
var image = px;
Reduce image into grayscale bitmap.
// reduce [r, g, b, a, ...] => [x, ...]px;
Expand back to original size and set alpha
to a random value.
// expand [x, ...] => [r, g, b, a, ...]px;
Output to file.
px;px;
Original | Processed PNG | Processed JPEG |
---|---|---|
All this in 5 lines of code. You can also access the image data directly through image.data
.
See test/test.js
.
API
read(file, type)
Reads an image file
into the specified type
(TypedArray
).
write(file, image)
Writes an image
to file
.
reduce(image, f)
Reduces blocks of data in an image
. Block size is inferred from the number of arguments in f
. See blockman.
expand(image, f)
Expands blocks of data in an image
. Block size is inferred from the number of arguments in f
. See blockman.
map(image, f)
Iterates and applies a mapping function over blocks of data in an image
. See blockman.