The `pngquant` package provides a Node.js readable/writable stream wrapper for the `pngquant` command-line utility. It allows developers to optimize PNG images by reducing their color palette directly within a Node.js stream pipeline, making it suitable for processing images from HTTP requests, file uploads, or other stream sources without requiring temporary files. Currently at version 4.2.0, its release cadence is not explicitly stated in the provided information, but it appears actively maintained given recent version bumps and project activity. Key differentiators include its efficient stream-based API, direct integration with the powerful `pngquant` CLI for high-quality optimization, and robust TypeScript type definitions for enhanced developer experience. This design simplifies image optimization workflows in server-side applications and microservices.
npm install pngquantVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to optimize a PNG file from a read stream to a write stream using custom `pngquant` command-line options within a Node.js pipeline.
Install the `pngquant` command-line utility via your system's package manager (e.g., `brew install pngquant` on macOS, `sudo apt install pngquant` on Debian/Ubuntu, or download from the official `pngquant` website).
Refer to the official `pngquant` command-line documentation for valid arguments and their syntax (e.g., run `pngquant --help` in your terminal). Test options thoroughly to ensure desired behavior.
Use `stream/promises.pipeline` for robust error handling and proper cleanup of streams in a chain. Alternatively, attach `error` event listeners to all individual streams in the pipeline (input, `PngQuant`, output) and handle errors appropriately.
Ensure the `pngquant` command-line utility is installed and its location is included in your system's PATH. Verify installation by running `pngquant --version` in your terminal.
Verify that the input stream provides a valid PNG image. Check the options array passed to the `PngQuant` constructor for correctness and compatibility with the `pngquant` CLI version and the input image (e.g., valid quality ranges, color counts).
No dependency data recorded yet.