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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pic-pipe

v4.2.0

Published

Tasks for working with pictures

Readme

pic-pipe

Pic-pipe is a set of tools for image buffers: Resizing based on orientation, automatically creating square thumbnails, compression within a desired filesize, extracting color values, uploading buffers to an AWS S3 bucket. It uses a common input/output object format for interoperability between functions.

If you need more precise control, or to work with non-buffers consider using the following libraries directly:

Sharp (image manipulation)

AWS JS SDK (for CDN storage and more)

get-pixels (get ndarray from image)

get-rgba-palette (get key colors from ndarray)

Chroma.js (color maniuplation)

Installation

npm install pic-pipe --save

Usage

Resize images automatically by proportions.

picPipe.resizeAndCompress(input, output);

input:

  • input.buffer {buffer}: Image buffer.
  • input.mimetype {string}: A string with the file mimetype.
  • input.maxPixel {number}: Desired maximum dimension in pixels. Largest side will not exceed this size.
  • input.maxByte {number}: (Default: 100000000) File size in bytes over which resizing will occur.
  • input.thumb {boolean}: (Optional) if true, maxByte is ignored and a square thumb based on maxPixel.

output returns a promise for asynchronous purposes due to potentially resizing large images. Use .then for success and .catch and errors:

  • err {object}: Contains the error object if there is an error.
  • input.buffer {buffer}: Resized image buffer.
  • input.size {number}: Size of new buffer.

myImage = {
	buffer: [buffer],
	mimetype: 'image/jpg',
	maxPixel: 2500,
	maxByte: 2500
};

picPipe.resizeAndCompress(myImage)
	.then(function (resized) {
		console.log(resized.buffer); // returns buffer object
		console.log(resized.size); // returns a number of bytes
	})
	.catch(function (err) {
		console.log(err); // returns an error object
	});

Pull colors from image

picPipe.colorPull(input, output);

input:

  • input.buffer {buffer}: Image buffer.
  • input.maxPixel {string}: A string with the image mimetype.

output callback:

  • err {object}: Contains the error object if there is an error.
  • input.picColors {array}: An array with up to 9 color values a hex strings.
  • input.colorAverage {string}: A single hex string

myImage = {
	buffer: [buffer],
	mimetype: 'image/jpg'
};

picPipe.colorPull(myImage, function(err, colors) {
	if (err) {
		throw new Error(err);
	}
	console.log(colors);
	// returns 2 color arrays. Examples:
	// picColors = ['#777777', '#888888', '#999999', '#aaaaaa', '#bbbbbb', '#cccccc', '#dddddd', '#eeeeee', '#ffffff']
	// colorAverage = '#808080'
});

Upload to S3 bucket

picPipe.bucketer(input).then(...);

input

  • input.buffer {buffer}: File buffer.
  • input.name {string}: A string with name of directory, filename, and extension.
  • input.bucket {string}: A string with the S3 bucket name.
  • input.mimetype {string}: A string with the file mimetype.

output:

  • err {object}: Contains the error object if there is an error.
  • output.eTag {string}: An added string that confirms valid upload.

AWS properties must also be set as enviromental parameters:

  • process.env.S3_KEY
  • process.env.S3_SECRET
  • process.env.AWS_REGION

myFile = {
	buffer: [buffer],
	name: 'my-directory/myfile.jpg',
	bucket: 'mybucket.amazonaws.com',
	mimetype: 'image/jpg'
};

picPipe.bucketer(myFile)
	.then((uploaded) => { // returns object with ETag if successful
		console.log(uploaded);
	})
	.catch((error) => {
		throw new Error(err);
	});

Tests

npm test