npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cornerstonejs/codec-openjpeg

v1.2.4

Published

JS/WebAssembly build of [OpenJPEG](https://github.com/uclouvain/openjpeg)

Downloads

44,070

Readme

openjpegjs

This library is a JavaScript port made possible by emscripten and Chris Hafey. It is a JavaScript and WebAssembly build of OpenJPEG.

Table of Contents

...

Features

Installing

Using npm:

$ npm install @cornerstonejs/openjpegjs

Using yarn:

$ yarn add @cornerstonejs/openjpegjs

Using unpkg CDN:

<script src="https://unpkg.com/@???/openjpegjs"></script>

Try It Out!

Try it in your browser here

openjpegjs API

Creating an instance

// JS / WASM promises resolve the library
const openjpegwasm = await OpenJPEGWASM;
const openjpegjs = await OpenJPEGJS;

// Decoder
const J2KDecoder = new openjpegjs.J2KDecoder();

// Encoder
const J2KEncoder = new openjpegjs.J2KEncoder();

Decoder instance methods

  • J2KDecoder#getEncodedBuffer([encodedBitStreamLength: int]): ArrayBuffer
  • J2KDecoder#getDecodedBuffer(): ArrayBuffer
  • J2KDecoder#readHeader(): ?
  • J2KDecoder#calculateSizeAtDecompositionLevel(decodeLevel: int): void
  • J2KDecoder#decode(): void
  • J2KDecoder#decodeSubResolution(decodeLevel: int, decodeLayer: int)
  • J2KDecoder#getFrameInfo(): FrameInfo
  • J2KDecoder#getNumDecomposition(): int
  • J2KDecoder#getIsReversible(): bool
  • J2KDecoder#getProgressionOrder(): int
  • J2KDecoder#getImageOffset(): Point
  • J2KDecoder#getTileSize(): Size
  • J2KDecoder#getTileOffset(): Point
  • J2KDecoder#getBlockDimensions(): Size
  • J2KDecoder#getNumLayers(): int
  • J2KDecoder#getColorSpace(): int
// ~ Setup
// const encodedArrayBuffer = ...;
const fullEncodedBitStream = new Uint8Array(encodedArrayBuffer);
const numBytes = 0;
const encodedBitStream = new Uint8Array(encodedArrayBuffer, 0, fullEncodedBitStream.length -numBytes);

// ~ DECODE
const encodedBuffer = decoder.getEncodedBuffer(encodedBitStream.length);
encodedBuffer.set(encodedBitStream);
decoder.decode(); // or .decodeSubResolution() to go by layer or level

// ~ Display (see example index.html file)
const decodedBuffer = decoder.getDecodedBuffer();
const frameInfo = decoder.getFrameInfo(); // width/height will be wrong if using decodeSubResolution
const interleaveMode = 2;

// In example index.html file
display(frameInfo, decodedBuffer, interleaveMode)

Encoder instance methods

  • J2KEncoder#getDecodedBuffer
  • J2KEncoder#getEncodedBuffer
  • J2KEncoder#encode
  • J2KEncoder#setDecompositions
  • J2KEncoder#setQuality
  • J2KEncoder#setProgressionOrder
  • J2KEncoder#setDownSample
  • J2KEncoder#setImageOffset
  • J2KEncoder#setTileSize
  • J2KEncoder#setTileOffset
  • J2KEncoder#setBlockDimensions
  • J2KEncoder#setNumPrecincts
  • J2KEncoder#setPrecinct
  • J2KEncoder#setCompressionRatio

Contributing

It can be difficult to contribute if your environment is not setup correctly. I highly recommend trying out VS Code's "Dev Containers" that make it easier to share and use a consistent development environment.

Dev Containers

Requirements

  1. VS Code and Docker Desktop
  2. Remote-Containers extension
  3. Command Pallete --> Remote-Containers: Open Folder in Container

How to Run

  • Run yarn install in the main codecs folder
  • Run git submodule update --init --recursive in the main codecs folder to initiate submodules
  • Go to packages/openjpeg folder
  • Run yarn build