posterize

1.0.2 • Public • Published

Posterize

Quickly make a poster from an ndarray image. Provide your own colors even.

Install

npm install posterize

Usage

var getPixels = require('get-pixels');
var savePixels = require('save-pixels');
var fs = require('fs');
 
var posterize = require('posterize');
 
getPixels('./path-to-image.jpg', function(err, pixels) {
  var poster = posterize(pixels, 3);
  savePixels(poster, 'jpg').pipe(fs.createWriteStream('./poster.jpg');
});

Arguments

posterize(pixels, colors, ?sort)

pixels (required)

This is an ndarray with a shape of [x, y, 3] or [x, y, 4]. Posterize only works on the rgb channels and clones the alpha channel if present.

colors (required)

This is either a number greater than zero or an array of rgb objects. If it is a number posterize will create colors based on its color reducing process. If its an array, the length of the array will determine the number of colors and the values will be used when setting the new images pixels.

an rgb object looks like:

{
  "red": 255,
  "green": 255,
  "blue": 255
}

sort (not required)

This is a non required boolean the defaults to true.

When colors is an array, sort can be passed to force posterize to resort the passed color array or not. If sort is true posterize will resort the provided colors to match color order of the poserized image.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    7
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    7
  • 1.0.1
    1
  • 1.0.0
    1

Package Sidebar

Install

npm i posterize

Weekly Downloads

9

Version

1.0.2

License

MIT

Last publish

Collaborators

  • mcwhittemore