npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

posterize

v1.0.2

Published

make a photo look like a poster

Downloads

8

Readme

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.