Code Monkey home page Code Monkey logo

node-bpg's Introduction

node-bpg

A nodejs wrapper that generating bpg image files by using pre-compiled libbpg binary.

For more information about libbpg, please visit (http://bellard.org/bpg/).

Install

Require: node >=6

npm install --save node-bpg

Example

encode .jpg or .png to .bpg

const { encode } = require('node-bpg');
const option = {
  qp: 10, // set quantizer parameter
  level: 9 // select the compression level
};

encode('input.jpg', 'output.bpg', option)
  .then(() => {
    // done
  });

decode .bpg to .png or .ppm

const { decode } = require('node-bpg');
const option = {
  bit_depth: 16 // set bit_depth per component (PNG output only)
};

decode('input.bpg', 'output.png', option)
  .then(() => {
    // done
  });

Options

encode 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)

Advanced options:
alphaq            set quantizer parameter for the alpha channel (default = same as qp value)
premul            store the color with premultiplied alpha
limitedrange      encode the color data with the limited range of video
hash              include MD5 hash in HEVC bitstream
keepmetadata      keep the metadata (from JPEG: EXIF, ICC profile, XMP, from PNG: ICC profile)
verbose           show debug messages

or refer to default option.

decode options

bit_depth         PNG output only: use bit_depth per component (8 or 16, default = 8)
information       display information about the image

Test

npm test

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

License

MIT

node-bpg's People

Contributors

thammin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

shovon

node-bpg's Issues

bpgenc did not return zero code?

child.on('exit', function(code) {
      if (code !== 0) {
        callback(new Error('Process bpgenc exited with non-zero code'));
      } else {
        callback();
      }
    });

Did catch the non-zero code instead.

Compilation failed

remote: libavcodec/hevc.c: In function 'ff_hevc_extract_rbsp':
remote: libavcodec/hevc.c:2898: warning: pointer targets in passing argument 2 of 'av_fast_malloc' differ in signedness
remote: ./libavutil/mem.h:373: note: expected 'unsigned int ' but argument is of type 'int *'
remote: make: *
* [libavcodec/hevc.o] Error 1

npm install not working

git submodule update --init won't work within npm install node-bpg
so we need to change the dependency from submodule to another method. ex:

  • publish dependency to npm registry
  • bower
  • hard code

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.