1.0.3 • Published 6 years ago

pixels-please v1.0.3

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

Pixels, Please

An image loading module for graphics applications.

  • Supports many popular image formats.
  • Image resizing.
  • Pixel data conversion for 32-bit texture formats.
  • Non-blocking image loading and processing.

Tested on Windows, Mac and Linux (including Raspberry Pi).

Requirements

  • Pixels, Please contains native code and requires a system with a proper C++ toolchain (node-gyp).

Install

npm install --save pixels-please
yarn add pixels-please
  • Installation requires node-gyp.

Examples

Asynchronously load image data into a Buffer.

const Pipeline = require('pixels-please');

Pipeline(imageFilename)
    .bytes({format: 'argb'})
    .toBuffer()
    .then(buffer => {
        // ...
    });

Synchronously load image data into a Buffer in 32 bit ARGB format.

const Pipeline = require('pixels-please');

let buffer = Pipeline(imageFilename)
    .bytes({format: 'argb'})
    .toBufferSync();

Read the image header for size information.

const Pipeline = require('pixels-please');

let header = Pipeline(imageFilename)
    .toHeaderSync();

console.log(`${header.width}x${header.height}`);

Resize an image to fit into a 100x100 bounding box, preserving aspect ratio.

const Pipeline = require('pixels-please');

let buffer = Pipeline(imageFilename)
    .bytes()
    .fit()
    .filter('gaussian')
    .resize(100, 100)
    .toBufferSync();

Image Formats

ExtensionLimitations
.jpgbaseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib)
.png1/2/4/8 bits per channel
.tgaNone
.bmpnon-RLE, non-1bpp
.psdcomposited view only, no extra channels, 8 bit-per-channel
.gifanimated not supported
.hdrradiance rgbE format
.picNone
.ppmbinary only
.pgmbinary only
.svgSupports a subset of SVG, including shapes, paths, etc.

License

Code is under the MIT License.