fast-png is a performant JavaScript library for encoding and decoding PNG image data, built entirely in JavaScript without native dependencies. The current stable version is 8.0.0, released in December 2025. This package focuses on speed, demonstrated by its recent switch to the `fflate` library for compression in v8.0.0. Major versions are released periodically (roughly annually), often introducing significant breaking changes like the migration to ESM in v7.0.0. It differentiates itself by offering a pure JavaScript implementation suitable for both Node.js and browser environments, while providing granular control over encoding options and supporting various PNG features like `tEXt` chunks, `tRNS` fields, and `ICC` profiles.
npm install fast-pngVerified import paths — ran on the pinned version, not inferred.
This quickstart encodes a simple 2x2 red image with metadata and then decodes it, verifying the pixel data and metadata.
Review the `encode` function documentation for updated `zlib` related options. Old options will likely cause errors or be ignored.
Update all imports to use ESM `import` statements. Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json` for Node.js).
Upgrade your Node.js runtime to a supported version (e.g., Node.js 16 or higher).
Review your code for any properties or methods that previously used uppercase acronyms (e.g., `CRCHash`) and update them to their camelCase equivalents (e.g., `crcHash`).
For robust error checking, always pass `{ checkCrc: true }` in the options object to the `decode` function.Ensure all text chunk keys are under 80 characters and both keys and values strictly adhere to the Latin-1 character set. Consider `iTXt` for full Unicode support if supported by the library.
Change `const { decode, encode } = require('fast-png');` to `import { decode, encode } from 'fast-png';`. Ensure your `package.json` has `"type": "module"` if running in Node.js, or use a bundler that handles ESM.Ensure the object passed to `encode` has at least `width`, `height`, `data`, `channels`, and `depth` properties, as specified in the API documentation.
Remove or update any `zlib` related options passed to `encode` as their structure or names may have changed with the switch to `fflate` in v8.0.0. Refer to the latest API documentation.
No dependency data recorded yet.