Small, fast and advanced PNG / APNG encoder and decoder
npm install @pdf-lib/upng
src="https://img.shields.io/npm/v/png-ts.svg?style=flat-square"
alt="NPM Version"
/>
> A small, fast and advanced PNG / APNG encoder and decoder
This project is a fork of UPNG.js and was created for use in 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) to makes TypeScript definitions available without requiring additional packages to be installed.
UPNG.toRGBA8javascript
// 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
$3
To install the latest stable version:
`bash
With npm
npm install --save @pdf-lib/upngWith yarn
yarn add @pdf-lib/upng
`
This assumes you're using npm or yarn as your package manager.$3
You can also download @pdf-lib/upng as a UMD module from unpkg. The UMD builds have been compiled to ES5, so they should work in any modern browser. UMD builds are useful if you aren't using a package manager or module bundler. For example, you can use them directly in the