image-stream-compress

1.0.9 • Public • Published

Image Stream Compress

npm version Publish

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

ISC

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

Package Sidebar

Install

npm i image-stream-compress

Weekly Downloads

92

Version

1.0.9

License

ISC

Unpacked Size

6.85 kB

Total Files

7

Last publish

Collaborators

  • bootsie123