https://github.com/Efferent-Health/Dicom
https://github.com/Efferent-Health/Dicom
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Efferent-Health/Dicom
- Owner: Efferent-Health
- License: mit
- Created: 2025-08-12T18:27:24.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-08-12T19:02:36.000Z (3 months ago)
- Last Synced: 2025-08-12T21:13:16.863Z (3 months ago)
- Language: TypeScript
- Size: 35.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-dicom - Efferent.Dicom - Ligthweight JS/TS/Node library for reading and writing DICOM files (Libraries / JavaScript)
README
# Efferent.Dicom
[](https://www.npmjs.com/package/efferent-dicom)
[](https://www.npmjs.com/package/efferent-dicom)
[](https://github.com/Efferent-Health/dicom)
Javascript library for reading and writing DICOM files in desktop, cloud and browser applications.
The following frameworks are supported:
- Browser (Javascript)
- NodeJS ESM
- NodeJS CJS
## API Overview
### Main classes
- DicomReader - DICOM reader and parser, with image extraction capabilities
- DicomWriter - DICOM creator and serializer
### Ancillary
- DicomElement - Main building block for DICOM files
- DICOM_TAG - Collection of commonly used DICOM tags
- PixelSpacing - Used for calibration purposes
## Usage
### Browser applications
If working with Typescript, include Efferent.Dicom.d.ts in your tsconfig.json file:
````json
"include": [
"./lib/Efferent.Dicom.d.ts",
// Other files
]
````
At runtime, add a reference to the script into your html header section:
````html
````
If preferred, you can use a CDN url like:
````html
````
You can also import the library using bundlers such as Webpack, Rollup, or Vite.
### NodeJS
The library is published on npm as `efferent-dicom`.
**ESM (ECMAScript Modules)**
If your project uses `"type": "module"` in `package.json` or has `.mjs` files:
```js
import { DicomReader, DICOM_TAG as TAG } from 'efferent-dicom';
```
**CommonJS (require syntax)**
If your project uses the default CommonJS module system:
```js
const { DicomReader, DICOM_TAG: TAG } = require('efferent-dicom');
```
**Note:**
- In CJS, destructuring syntax uses `DICOM_TAG: TAG` to rename the constant.
- In ESM, you can directly alias using `as TAG`.
#### Example
```js
import fs from 'fs';
import { DicomReader, DICOM_TAG as TAG } from 'efferent-dicom';
const data = fs.readFileSync('example.dcm');
const parser = new DicomReader(new Uint8Array(data.buffer));
console.log(parser.DicomTags[TAG.PATIENT_NAME]);
```
## Demos
There are two demo applications:
### NodeJS
Run node/dicomdump.js to print in the console detailed DICOM tags, using the command:
````sh
node ./demo/node/dicomdump.js
````
### Browser
Open demo/index.html for an interactive demo that can read a DICOM file (.dcm extension), show a summary and a picture (only for .50 JPEG transfer syntax), as well as detailed DICOM tags
