<commit_before># node-bpg

> A nodejs wrapper that generating bpg image files by using pre-compiled libbpg (http://bellard.org/bpg/).

* This wrapper is still under development ..slowly, PR would be appreciated!

## Install

Install with [npm](https://npmjs.org/package/gulp-react)

```
npm install --save-dev node-bpg
```


## Example

###use with gulp plugin
coming soon..

###use with optional config
```js
var config = {
  qp: 10, // set quantizer parameter
  level: 9 // select the compression level
};
var bpg = require('node-bpg')(config);

bpg.encode('./input.jpg', function(err) {
  if (err) throw err;
});
```


## Options

```
qp                set quantizer parameter (smaller gives better quality, range: 0-51, default = 28)
cfmt              set the preferred chroma format (420, 422, 444, default = 420)
color_space       set the preferred color space (ycbcr, rgb, ycgco, ycbcr_bt709, ycbcr_bt2020, default = ycbcr)
bit_depth         set the bit depth (8 to 12, default = 8)
lossless          enable lossless mode
encoder           select the HEVC encoder (jctvc, default = jctvc)
level             select the compression level (1 = fast, 9 = slow, default = 8)
<commit_msg>update example usage of bpg.encode<commit_after># node-bpg

> A nodejs wrapper that generating bpg image files by using pre-compiled libbpg (http://bellard.org/bpg/).

* This wrapper is still under development ..slowly, PR would be appreciated!

## Install

Install with [npm](https://npmjs.org/package/gulp-react)

```
npm install --save-dev node-bpg
```


## Example

###use with gulp plugin
coming soon..

###use with optional config
```js
var config = {
  qp: 10, // set quantizer parameter
  level: 9 // select the compression level
};
var bpg = require('node-bpg')(config);

var inputName = './input.jpg';
var outputName = './output.bpg';

// with output name
bpg.encode(inputName, outputName, function(err) {
  if (err) throw err;
  console.log(inputName + ' -> ' + outputName);
});

// without output name (input.bpg)
bpg.encode(inputName, function(err) {
  if (err) throw err;
  console.log(inputName + ' -> input.bpg');
});

```


## Options

```
qp                set quantizer parameter (smaller gives better quality, range: 0-51, default = 28)
cfmt              set the preferred chroma format (420, 422, 444, default = 420)
color_space       set the preferred color space (ycbcr, rgb, ycgco, ycbcr_bt709, ycbcr_bt2020, default = ycbcr)
bit_depth         set the bit depth (8 to 12, default = 8)
lossless          enable lossless mode
encoder           select the HEVC encoder (jctvc, default = jctvc)
level             select the compression level (1 = fast, 9 = slow, default = 8)

{'fraction_non_alphanumeric': 0.12141527001862197, 'fraction_numerical': 0.02532588454376164, 'mean_word_length': 3.1903276131045244, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6105620', 'n_tokens_mistral': 921, 'n_tokens_neox': 830, 'n_words': 304}