Code Monkey home page Code Monkey logo

j2k.js's Introduction

j2k.js

This is a port of OpenJPEG, an open-source JPEG2000 codec, to JavaScript using Emscripten.

Why? JPEG2000 is useful sometimes, and web browsers don't have native support for it, so having a pure JS decoder is a nice option to have.

Usage

Grab openjpeg.js which is an optimized and minified build. Then you simply call

    openjpeg(data, suffix)

with the first argument being an array of values in 0-255 (representing a file in binary format), and the second argument being the suffix of the file (there is no autodetection of the file type in OpenJPEG, and whether it is a .jp2 or .j2k does actually matter it turns out). The function returns a a JSON object of form

    {
      width: the width
      height: the height
      data: the pixel data (in 24-bit "Planar RGB" format)
    }

See test.js for a concrete example (it is called by test.py).

Note: j2k.js by default requires typed arrays. You can also build it without typed arrays, but it will be much slower (see below).

Building

(You don't normally need to do this.)

Do

    python make.py

Note: Looks like you need |make clean| in build/ as incremental builds do not always link.

You can modify the settings in make.py. For example, changing USE_TYPED_ARRAYS to 0 will make it generate a build without typed arrays (which as mentioned above, will be slower but will work if the environment lacks typed arrays).

Testing

Run

    python test.py openjpeg.js

The generated files are written to generated.raw. You can view them in GIMP by opening them as RAW (select "all files", then "select file type" as raw, and pick "generated.raw"). You should select "Planar RGB" as the format, and enter the right width and height.

You should also make sure that examples/simple.html and examples/worker.html both work properly in a web browser.

j2k.js's People

Contributors

kripken avatar arturadib avatar

Watchers

James Cloos avatar

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.