A tool to convert DICOM series to GIF/APNG/TIFF format.
Project description
dicom2gif
A Python tool to convert DICOM series to GIF/APNG/TIFF format
Features
- Convert enhanced (multi-frame) and legacy DICOM series to GIF, APNG, or TIFF
- Automatic detection of frame duration from DICOM metadata
- Support for windowing (brightness/contrast) adjustment
- Batch processing of entire directories
Installation
pip install dicom2gif
Usage
Command Line
After installation, dicom2gif can be used as a command line tool.
When given a directory, the tool will recursively search for DICOM files with the same Series Instance UID and create a separate movie file for each series.
dicom2gif [-h] [-p PATTERN] [-o OUT_FILE] [-f {gif,apng,tiff}] [-d DURATION] [-w WINDOWING] dcm_path
Options:
dcm_path: Input DICOM file or directory-p, --pattern: Pattern to select DICOM files whendcm_pathis a directory (defaults to *.dcm)-o, --out_file: Output file path (defaults to input name with .gif extension)-f, --format: Output file format, can be gif, apng, or tiff (ignored if--out_fileis given)-d, --duration: Duration per frame in milliseconds (optional, auto-detected from DICOM if available)-w, --windowing: Can be two comma-separated integers for window center and width, 'dicom' for windowing parameters from DICOM metadata, or 'full' for windowing to full dynamic range (defaults to 'dicom')
Python API
from dicom2gif import dicom2gif, read_dcm, read_dir, write
# Single enhanced DICOM file
series = read_dcm("path/to/file.dcm")
write(series, "output.gif", duration=50)
# Directory of DICOM files
all_series = read_dir("path/to/directory")
for path, series in all_series.items():
out_file = path.with_suffix(".apng")
write(series, out_file, windowing="dicom")
# Or directly
dicom2gif("path/to/file.dcm", out_file="output.gif", duration=50)
dicom2gif("path/to/directory", format="apng", windowing="full")
Requirements
- Python ≥ 3.10
- numpy
- Pillow ≥ 7.1.2
- pydicom
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dicom2gif-1.0.0.tar.gz.
File metadata
- Download URL: dicom2gif-1.0.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c2fc4bf0f3f61869d9ae550166c5d67312244f122710c10cb0ef5b14f788f07
|
|
| MD5 |
7e6d84c2afdf2ba5474f520bdb763257
|
|
| BLAKE2b-256 |
602ec5f6faca5103a373c5c9a4e1ef38e3ae291edb305b374c5c3f4aef9aed87
|
Provenance
The following attestation bundles were made for dicom2gif-1.0.0.tar.gz:
Publisher:
publish-to-pypi.yml on marcvornehm/dicom2gif
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dicom2gif-1.0.0.tar.gz -
Subject digest:
2c2fc4bf0f3f61869d9ae550166c5d67312244f122710c10cb0ef5b14f788f07 - Sigstore transparency entry: 926879776
- Sigstore integration time:
-
Permalink:
marcvornehm/dicom2gif@67af0539ec75c53d58eb8ab40c67e757b63e9482 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/marcvornehm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@67af0539ec75c53d58eb8ab40c67e757b63e9482 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dicom2gif-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dicom2gif-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12f27997410ef804b04b7fcb651548faff5c325252eae65ffb00c5dc3ab8c911
|
|
| MD5 |
dc29c378f3c67630f5ed0e0bf4cd9ebd
|
|
| BLAKE2b-256 |
bd0f87c29b3a60ed18e20d285964f3cbd297ce385b4c09a0e8399bc1d21673b2
|
Provenance
The following attestation bundles were made for dicom2gif-1.0.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on marcvornehm/dicom2gif
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dicom2gif-1.0.0-py3-none-any.whl -
Subject digest:
12f27997410ef804b04b7fcb651548faff5c325252eae65ffb00c5dc3ab8c911 - Sigstore transparency entry: 926879778
- Sigstore integration time:
-
Permalink:
marcvornehm/dicom2gif@67af0539ec75c53d58eb8ab40c67e757b63e9482 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/marcvornehm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@67af0539ec75c53d58eb8ab40c67e757b63e9482 -
Trigger Event:
release
-
Statement type: