image-stream-compress
v1.0.9
Published
Compresses image streams using pngquant and mozjpeg
Downloads
454
Maintainers
Readme
Image Stream Compress
An image compression library for image streams (modified from node-pngquant). Uses pngquant and mozjpeg for compression
Installation
Simply install the npm module and you are good to go!
npm install image-stream-compress
Usage
const fs = require("fs");
const { BaseStream, PNGQuant, MozJPEG } = require("image-stream-compress");
const input = fs.createReadStream("image.png");
const output = fs.createReadStream("output.png");
const compress = new PNGQuant([ 256, "--speed", 5, "--quality", "65-80" ]);
input.pipe(compress)
.pipe(output)
.on("finish", () => console.log("Image compressed!"));
API
BaseStream (extends Stream)
constructor(binaryPath: String, args: String[])
PNGQuant (extends BaseStream)
constructor(args: String[]) A full list of args can be found here
MozJPEG (extends BaseStream)
constructor(args: String[]) A full list of args can be found here
Contributing
Pull requests are welcome. Any changes are appreciated!
License
Acknowledgments
- node-pngquant - Special thanks to all of the contributors who worked on that project! This project is a slight modfication of their project to make it used for more general purposes