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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dcmjs-codecs

v0.0.6

Published

DICOM file and dataset transcoding for Node.js and browser using dcmjs

Downloads

8,732

Readme

NPM version NPM downloads build MIT License

dcmjs-codecs

DICOM file and dataset transcoding for Node.js and browser using Steve Pieper's dcmjs library.

Note

This effort is a work-in-progress and should not be used for production or clinical purposes.

Install

Node.js

npm install dcmjs-codecs

Browser

<script type="text/javascript" src="https://unpkg.com/dcmjs"></script>
<script type="text/javascript" src="https://unpkg.com/dcmjs-codecs"></script>

Build

npm install
npm run build

Build codecs WebAssembly (optional)

cd wasm
./build.sh

Emscripten SDK (emsdk) is required.

Supported Transfer Syntaxes

  • Implicit VR Little Endian (1.2.840.10008.1.2)
  • Explicit VR Little Endian (1.2.840.10008.1.2.1)
  • Explicit VR Big Endian (1.2.840.10008.1.2.2)
  • RLE Lossless (1.2.840.10008.1.2.5)*
  • JPEG Baseline - Process 1 (1.2.840.10008.1.2.4.50)*
  • JPEG Lossless, Nonhierarchical, First-Order Prediction - Processes 14 [Selection Value 1] (1.2.840.10008.1.2.4.70)*
  • JPEG-LS Lossless Image Compression (1.2.840.10008.1.2.4.80)*
  • JPEG-LS Lossy Image Compression - Near-Lossless (1.2.840.10008.1.2.4.81)*
  • JPEG 2000 Image Compression - Lossless Only (1.2.840.10008.1.2.4.90)*
  • JPEG 2000 Image Compression (1.2.840.10008.1.2.4.91)*
  • High Throughput JPEG 2000 Image Compression - Lossless Only (1.2.840.10008.1.2.4.201)*
  • High Throughput JPEG 2000 with RPCL Options Image Compression - Lossless Only (1.2.840.10008.1.2.4.202)*
  • High Throughput JPEG 2000 Image Compression (1.2.840.10008.1.2.4.203)*

*: Syntax is transcoded using the codecs WebAssembly.

Usage

Basic image transcoding

// Import objects in Node.js
const dcmjsCodecs = require('dcmjs-codecs');
const { NativeCodecs, Transcoder } = dcmjsCodecs;
const { TransferSyntax } = constants;

// Import objects in Browser
const { NativeCodecs, Transcoder } = window.dcmjsCodecs;
const { TransferSyntax } = constants;

// Register native codecs WebAssembly.
await NativeCodecs.initializeAsync();

// Create an ArrayBuffer with the contents of the DICOM P10 byte stream.
const transcoder = new Transcoder(arrayBuffer);

// Transcode to a different transfer syntax UID.
transcoder.transcode(TransferSyntax.JpegLosslessProcess14V1);

// Get the transcoded DICOM P10 byte stream in an ArrayBuffer.
const transcodedArrayBuffer = transcoder.getDicomPart10();

Advanced image transcoding

// Import objects in Node.js
const dcmjsCodecs = require('dcmjs-codecs');
const { NativeCodecs, Transcoder } = dcmjsCodecs;
const { Jpeg2000ProgressionOrder, TransferSyntax } = constants;

// Import objects in Browser
const { NativeCodecs, Transcoder } = window.dcmjsCodecs;
const { Jpeg2000ProgressionOrder, TransferSyntax } = constants;

// Create native codecs WebAssembly initialization options.
const initOpts = {
  // Optionally, provide the path or URL to WebAssembly module.
  // If empty or undefined, the module is trying to be resolved 
  // within the same directory.
  webAssemblyModulePathOrUrl: undefined,
  // Optional flag to enable native codecs informational message logging.
  // If not provided, the native codecs informational message logging is disabled.
  logCodecsInfo: false,
  // Optional flag to enable native codecs trace message logging.
  // If not provided, the native codecs trace message logging is disabled.
  logCodecsTrace: false
};
await NativeCodecs.initializeAsync(initOpts);

// Create an ArrayBuffer with the contents of the DICOM P10 byte stream.
const transcoder = new Transcoder(arrayBuffer);

// Create encoding and decoding options.
const encodingDecodingOpts = {
  // JPEG encoding params
  // Optional JPEG quality, in case of JPEG baseline encoding.
  // Sets the libjpeg jpeg_set_quality quality input variable.
  quality: 90,

  // JPEG-LS encoding params
  // Optional JPEG-LS quality, in case of JPEG-LS lossy encoding.
  // Sets the charls allowedLossyError variable.
  allowedLossyError: 10,

  // JPEG 2000 and HT-JPEG 2000 encoding params
  // Optional JPEG progression order, in case of JPEG 2000 and HT-JPEG 2000 encoding.
  progressionOrder: Jpeg2000ProgressionOrder.Lrcp,
  // Optional JPEG 2000 quality, in case of JPEG 2000 lossy encoding.
  // Sets the openjpeg tcp_rates[0] variable.
  rate: 20
};

// Transcode to a different transfer syntax UID.
transcoder.transcode(TransferSyntax.Jpeg2000Lossless, encodingDecodingOpts);

// Get the transcoded DICOM P10 byte stream in an ArrayBuffer.
const transcodedArrayBuffer = transcoder.getDicomPart10();

Please check a live example here.

Related libraries

  • dcmjs-dimse - DICOM DIMSE implementation for Node.js using dcmjs.
  • dcmjs-imaging - DICOM image and overlay rendering for Node.js and browser using dcmjs.

License

dcmjs-codecs is released under the MIT License.