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 🙏

© 2025 – Pkg Stats / Ryan Hefner

pixel-converters

v0.0.1

Published

Simple conversion of pixels to RGB and RGBA, including automatic scaling and reserved values.

Readme

beta version

pixel-converters:

Simple conversion of pixels to RGB and RGBA, including automatic scaling and no data values.

features

  • immutable

core assumptions and constraints

An RGB pixel has these assumed properties:

  • array of 3 numbers between zero and 255
  • no data values represented by [0, 0, 0] or [255, 255, 255]

An RGBA pixel has these assumed properties:

  • array of 4 numbers between zero and 255
  • the first 3 numbers are "data" values and the last value is an alpha tranparency value
  • an alpha value of 0 indicates that at least one of the data bands is "no data"
  • there may be a per-band no data value, but it is not required

A raw (unscaled) pixel value has these assumed properties:

  • between 1 and inifinity number of bands
  • number can be any valid number
  • no data value is the same for each band
  • there is no transparency channel/band

install

npm install pixel-converters

functions

  • convert_raw_to_rgb
  • convert_raw_to_rgba
  • convert_rgb_to_rgba
  • convert_rgba_to_rgb
  • create_nodata_rgb
  • create_nodata_rgba
  • has_no_data_value
  • hide_rgba
  • scale_number
  • scale_band_value
  • scale_band_value_holding_bottom
  • scale_band_value_holding_top
  • show_rgba

usage

convert_raw_to_rgb

You normally want to convert a raw pixel to an RGB 3-Band pixel when you are looking to save your pixel to a JPG file.

import { convert_raw_to_rgb } from "pixel-converters";

// example is a pixel in a Landsat 8 scene
const pixel = [5901];
const min = 0;
const max = 62196;
const old_no_data_value = 65536;
convert_raw_to_rgb(pixel, [min], [max], old_no_data_value);
[24, 24, 24]

// if you want to hold zero as the new no data value
// in other words, a no data pixel will be [0, 0, 0]
// because zero is taken, it will push all the scaled values up
convert_raw_to_rgb(pixel, [min], [max], old_no_data_value, 0);
[24, 24, 24]

// if you want your no data pixel to be pure white ([255, 255, 255])
// you can set the new no data value to 255
// this will push all the scaled pixel values down
convert_raw_to_rgb(pixel, [min], [max], old_no_data_value, 255);
[24, 24, 24]

convert_raw_to_rgba

You normally want to convert a raw pixel to an RGB 3-Band pixel when you are looking to save your pixel to a PNG file, HTML canvas, or another representation that supports an alpha band (transparency channel).

import { convert_raw_to_rgba } from "pixel-converters";

// using same pixel as above
convert_raw_to_rgba(pixel, [min], [max], old_no_data_value);
[24, 24, 24, 255]

// using same pixel as above, but reserving 0 for the new no data value
convert_raw_to_rgba(pixel, [min], [max], old_no_data_value, 0);
[24, 24, 24, 255]

// using same pixel as above, but reserving 255 for the new no data value
convert_raw_to_rgba(pixel, [min], [max], old_no_data_value, 255);
[24, 24, 24, 255]

more documentation coming soon

as time permits...