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

image-output

v2.4.2

Published

Output image data to a file, console, canvas, array or buffer

Downloads

8,374

Readme

image-output Build Status unstable

Output image data to a destination: file, canvas, console, stdout, ImageData etc.

Usage

$ npm install image-output

var output = require('image-output')

// create chess pattern png from raw pixels data
output({
	data: [0,0,0,1, 1,1,1,1, 1,1,1,1, 0,0,0,1],
	width: 2,
	height: 2
}, 'chess.png')

API

output(source, destination?, shape|options?)

Output pixel data source to a destination based on options. Undefined destination displays image to console/stdout. The operation is done in sync fashion. destination and options may come in the opposite order for conveniency.

output([0,1,1,0], [2,2,1], 'a.png')

source

Shoud be an actual image data container, one of:

  • Canvas, Context2D, WebGLContext
  • ImageData or Object {data: Uint8Array, width, height}
  • DataURL or base64 string
  • Image, Video, ImageBitmap with resolved data
  • Array, Array of Arrays, Uint8Array, FloatArray with raw pixels
  • ArrayBuffer, Buffer
  • Ndarray

Handy for that purpose is image-pixels:

var pixels = require('image-pixels')
output(await pixels('image.png'), 'image-copy.png')

destination

Can be any image output destination:

Type | Meaning ---|--- String | File to create or path, in node. If includes extension, mimeType is detected from it. Canvas2D, Context2D | Render pixel data into a canvas. Canvas is resized to fit the image data. To avoid resizing, use options.clip property. document, Element | Create a canvas with diff data in document or element. console | Display image to console in browser or to terminal in node. Array / FloatArray | Write pixel data normalized to [0..1] range to a float-enabled array. UintArray | Put pixel data to any unsigned int array. Buffer / ArrayBuffer | Put pixel data into a buffer, possibly encoded into target format by options.type. Ndarray | Write pixel data into an ndarray. ImageData | Put data into ImageData instance, browser only. Object | Create data, width and height properties on an object. Function | Call a function with ImageData as argument. Stream | Send data to stream, eg. process.stdout. WebStream | TODO. Send data to stream, eg. process.stdout.

options

Property | Meaning ---|--- type / mime | Encode into target type, by default detected from file extension. By default image/png. quality | Defines encoding quality, 0..1, optional. By default 1. ...rest | Rest of options is passed to encoder.

Customize color palette in terminal

You can choose color palette with flags or environment variable FORCE_COLOR=0123

node ./script.js --no-color
node ./script.js --color
node ./script.js --color=256
node ./script.js --color=16m

Related

Similar

License

© 2018 Dmitry Yv. MIT License.