Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/image-js/fast-png
PNG image decoder and encoder written entirely in JavaScript
https://github.com/image-js/fast-png
hacktoberfest image image-decoder image-encoder javascript nodejs png
Last synced: 11 days ago
JSON representation
PNG image decoder and encoder written entirely in JavaScript
- Host: GitHub
- URL: https://github.com/image-js/fast-png
- Owner: image-js
- License: mit
- Created: 2015-09-24T07:57:54.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2024-02-13T12:31:02.000Z (9 months ago)
- Last Synced: 2024-10-27T14:25:35.592Z (17 days ago)
- Topics: hacktoberfest, image, image-decoder, image-encoder, javascript, nodejs, png
- Language: TypeScript
- Homepage:
- Size: 477 KB
- Stars: 334
- Watchers: 8
- Forks: 19
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# fast-png
PNG image decoder and encoder written entirely in JavaScript.
Maintained by Zakodium
[![NPM version][npm-image]][npm-url]
[![build status][ci-image]][ci-url]
[![npm download][download-image]][download-url]## Installation
`$ npm install --save fast-png`
## Usage
### `decode(png[, options])`
#### Arguments
- `png` - A TypedArray or Buffer that contains the PNG data.
- `options` - An object of options#### Options
- `checkCrc` - If set to `true`, the CRC will be checked for each chunk and an error will be thrown in case it's wrong (default: false).
### `encode(image)`
#### Arguments
- `png` - An object representing the image. You can pass an ImageData from the Canvas API or an object with the following properties:
- `width` - The width of the image
- `height` - The height of the image
- `data` - An array or TypedArray with the image data
- `depth` - A number indicating the color depth (only 8 and 16 are supported now). Default: `8`.
- `channels` - Number of channels, including alpha (1, 2, 3 and 4 are supported). Default: `4`.
- `text` - An object with key-value pairs representing `tEXt` chunks. The keys must have less than 80 characters.
The keys and values must have only characters in the latin1 charset (maximum code point of 255).
Default: `undefined`.### `hasPngSignature(array)`
Returns whether the array starts with the PNG signature (magic bytes).
## PNG standard
Spec can be found at: https://www.w3.org/TR/PNG/
## License
[MIT](./LICENSE)
[npm-image]: https://img.shields.io/npm/v/fast-png.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/fast-png
[ci-image]: https://github.com/image-js/fast-png/workflows/Node.js%20CI/badge.svg?branch=main
[ci-url]: https://github.com/image-js/fast-png/actions?query=workflow%3A%22Node.js+CI%22
[download-image]: https://img.shields.io/npm/dm/fast-png.svg?style=flat-square
[download-url]: https://www.npmjs.com/package/fast-png