pix

pixels

Image processing library

Showing:

Popularity

Downloads/wk

0

GitHub Stars

7

Maintenance

Last Commit

6yrs ago

Contributors

0

Package

Dependencies

4

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

pixels

Pixels is a tiny image processing library written in JavaScript.

$ npm install pixels
$ npm test
var px = require('pixels');

Currently supports read/write for PNG and JPEG.

Usage

Read image into a Float64Array.

var image = px.read('./test/input.jpg', Float64Array);

Reduce image into grayscale bitmap.

// reduce [r, g, b, a, ...] => [x, ...]
px.reduce(image,
  (r, g, b, a) =>
    0.2126 * r +
    0.7152 * g +
    0.0722 * b
);

Expand back to original size and set alpha to a random value.

// expand [x, ...] => [r, g, b, a, ...]
px.expand(image,
  (x) =>
    [x, x, x, Math.random()]
);

Output to file.

px.write('./test/output.png', image);
px.write('./test/output.jpg', image);
OriginalProcessed PNGProcessed JPEG
originalpngjpeg

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.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial