Utility Functions for Pixels
npm install pixel-utils⚠️ This library is currently in beta, so the function signatures are subject to change.
---
bash
npm install pixel-utils
`functions
- conversion
- rawToRgb - convert a raw unprocessed pixel value to RGB
- rawToRgba - convert a raw unprocessed pixel value to RGBA
- rgbToRgba - convert from RGB to RGBA
- rgbaToRgb - convert from RGBA to RGB
- no data
- makeNoDataRgb - create a no data RGB pixel
- makeNoDataRgba - create a no data RGB pixel
- iteration
- eachPixel - call a callback for each pixel
- selection
- select - select a pixel from image data of arbitrary dimensions
- transparency
- addAlpha - add an alpha transparency channel
- isHidden - check if an RGBA pixel is transparent
- setHidden - mutates input pixel, setting alpha channel to visible
- showRGBA` - make RGBA visibleAn 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 must be the same for each band (we don't love this, but it's a common constraint)
- there is no transparency channel/band (we may work to remove this constraint)