png-stream
A streaming PNG encoder and decoder for Node and the browser. Supports animated PNGs and normal still PNGs.
Installation
npm png-stream
For the browser, you can build using Browserify.
Decoding
This example uses the concat-frames module to collect the output of the PNG decoder into an array of frame objects.
var PNGDecoder = ;var concat = ; // decode a PNG file to RGB pixelsfs ;
Encoding
You can encode a PNG by writing or piping pixel data to a PNGEncoder
stream.
The PNG encoder supports writing data in the RGB, RGBA, grayscale (gray
),
and grayscale + alpha (gray
) color spaces. You can also write data in the
indexed
color space by first quantizing it using the neuquant
module.
var PNGEncoder = ;var neuquant = ; // convert a JPEG to a PNGfs ; // write indexed datafs ;
License
MIT