upng
NPM Version

> A small, fast and advanced PNG / APNG encoder and decoder This project is a fork of [`UPNG.js`](https://github.com/photopea/UPNG.js) and was created for use in [`pdf-lib`](https://github.com/Hopding/pdf-lib). The maintainer of the original repo does not publish it to NPM. That is the primary purpose of this fork. In addition, an `index.d.ts` file has been added (copied directly from [`@types/upng-js`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/upng-js/index.d.ts)) to makes TypeScript definitions available without requiring additional packages to be installed. ## Example of `UPNG.toRGBA8` ```javascript // Import the UPNG class import UPNG from '@pdf-lib/upng'; // Create a UPNG object const pngImage = UPNG.decode(/* Uint8Array containing bytes of PNG image */); // `pixels` is a 1D array (in rgba order) of decoded pixel data const pixels = pngImage.UPNG.toRGBA8(); ``` ## Installation ### NPM Module To install the latest stable version: ```bash # With npm npm install --save @pdf-lib/upng # With yarn yarn add @pdf-lib/upng ``` This assumes you're using [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/lang/en/) as your package manager. ### UMD Module You can also download `@pdf-lib/upng` as a UMD module from [unpkg](https://unpkg.com/#/). The UMD builds have been compiled to ES5, so they should work [in any modern browser](https://caniuse.com/#feat=es5). UMD builds are useful if you aren't using a package manager or module bundler. For example, you can use them directly in the `