# node-pngquant-native

> A pngquant addon of node

Latest version **2.2.0** (published 2020-06-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-pngquant-native
pnpm add node-pngquant-native
yarn add node-pngquant-native
bun add node-pngquant-native
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2020-06-03 |
| First published | 2013-07-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 323.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 46 |
| Author | xiangshouding |
| Maintainers | 2betop, fansekey, fis-dev |
| Keywords | fis, png, pngquant, image, reduce, ie6 |

## Links

- npm: https://www.npmjs.com/package/node-pngquant-native
- Repository: https://github.com/xiangshouding/node-pngquant-native
- Homepage: https://github.com/xiangshouding/node-pngquant-native#readme
- Issues: https://github.com/xiangshouding/node-pngquant-native/issues
- npm.io page: https://npm.io/package/node-pngquant-native

## Dependencies (1)

- [semver](https://npm.io/package/semver.md) ^5.6.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 2.2.0 (latest) — 2020-06-03
- 2.1.3 — 2020-05-19
- 2.1.2 — 2020-05-14
- 2.1.1 — 2019-01-11
- 2.1.0 — 2019-01-11
- 2.0.1 — 2017-09-20
- 1.0.5 — 2017-06-28
- 1.0.4 — 2016-05-11
- 1.0.3 — 2016-02-25
- 1.0.2 — 2015-10-29
- 1.0.1 — 2015-10-12
- 1.0.0 — 2015-10-03
- 0.2.3 — 2015-05-12
- 0.2.2 — 2015-05-12
- 0.1.2 — 2015-04-17
- … 14 more at https://npm.io/package/node-pngquant-native/versions

## README

## node-pngquant-native
[![NPM version](https://badge.fury.io/js/node-pngquant-native.png)](http://badge.fury.io/js/node-pngquant-native)

node-pngquant-native is an addon of node, support node version v0.8.0 to latest, It compress a `buffer` of `.png` image, so can't call other processes.

## install

    npm install -g node-pngquant-native
    

## make

if install fail for you. download the source install it.

1. clone source code

    ```bash
    $ git clone https://github.com/xiangshouding/node-pngquant-native.git
    ```

2. invoke `npm install -g .`

    ```bash
    $ cd node-pngquant-native
    $ npm install -g .
    ```

### require

+ make pngqunat, your compiler must support C99
+ install `node-gyp`, you can see detail information [https://github.com/TooTallNate/node-gyp#installation](https://github.com/TooTallNate/node-gyp#installation)
+ For WINDOWS user, please clone branch `win32`, because VS not support C99.

## use

```javascript

var pngquant = require('node-pngquant-native');

fs.readFile('./alphatest.png', function (err, buffer) {
  if (err) throw err;
  var resBuffer = pngquant.compress(buffer, {
    "speed": 1 //1 ~ 11
  });

  fs.writeFile('./alphatest_out.png', resBuffer, {
      flags: 'wb'
  }, function(err){});
});

```

## Api

### pngquant.`compress(buffer, option)`

```javascript
var pngquant = require('node-pngquant-native')
var option = {
    speed: 11
    //...    
}

var resBuffer = pngquant.compress(buffer, option);

```
#### option

+ option.`speed` 

    Speed/quality trade-off from 1 (brute-force) to 11 (fastest). The default is 3. Speed 10 has 5% lower quality, but is 8 times faster than the default. Speed 11 disables dithering and lowers compression level.

    ```javascript
    var opt = {
        speed: 11
    }
    ```

+ option.`quality = [min, max]`

    min and max are numbers in range 0 (worst) to 100 (perfect), similar to JPEG. pngquant will use the least amount of colors required to meet or exceed the max quality. If conversion results in quality below the min quality the image won't be saved (if outputting to stdin, 24-bit original will be output) and pngquant will exit with status code 99.

    ```javascript
    var opt = {
        quality: [40, 60]
    }
    ```

+ option.`iebug`
    
    Workaround for IE6, which only displays fully opaque pixels. pngquant will make almost-opaque pixels fully opaque and will avoid creating new transparent colors.

    ```javascript
    var opt = {
        iebug: true
    }
    ```

## ChangeLog

### 1.0.5

- support node 8.x on MacOS

---
_Source: https://npm.io/package/node-pngquant-native · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
