Download the PHP package rbraunm/class_dicom without Composer
On this page you can find all versions of the php package rbraunm/class_dicom. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rbraunm/class_dicom
More information about rbraunm/class_dicom
Files in rbraunm/class_dicom
Package class_dicom
Short Description PHP library for DICOM tag handling, image conversion, compression, and networking via DCMTK
License MIT
Informations about the package class_dicom
class_dicom.php
A PHP library for working with DICOM medical images. Handles tag reading and writing, JPEG conversion, compression, and DICOM networking (C-ECHO, C-STORE send and receive) by wrapping the DCMTK command-line toolkit.
Originally created by Dean Vaughan (deanvaughan.org).
Requirements
- PHP 8.0 or later (CLI or web)
- DCMTK command-line utilities installed and accessible
By default the library looks for DCMTK binaries in /usr/local/bin. If your installation is elsewhere, edit the TOOLKIT_DIR constant at the top of class_dicom.php.
On Debian/Ubuntu:
Installation
Composer
Manual
Copy class_dicom.php into your project and require it directly:
Usage
Reading DICOM tags
The constructor calls load_tags() automatically if the file exists and passes the is_dcm() check. Tags can also be loaded manually:
Writing DICOM tags
This modifies the file in place using dcmodify.
Converting DICOM to JPEG
Compression and decompression
Converting JPEG to DICOM
Known issue:
jpg_to_dcm()treats any output fromxml2dcmas a fatal error. The bundled XML template (examples/jpg_to_dcm.xml) produces a SOPInstanceUID mismatch warning on current DCMTK versions, which causes the function to return early without embedding pixel data. The resulting file is a valid DICOM header but contains no image. This will be fixed in v2.0.0.
The intended usage (once fixed) follows the pattern in examples/jpg_to_dcm.php:
The tag keys must match the (group,element) placeholders in the XML template. See examples/jpg_to_dcm.php for the full tag mapping.
Multiframe DICOM to video
Requires ffmpeg on the system.
DICOM networking
See examples/store_server.php, examples/store_server_handler.php, and examples/store_server_config.cfg for a working receive setup.
Utility functions
Testing
The test suite uses PHP + DCMTK for the code under test and Python for independent validation. This ensures DICOM files produced by the library are verified by a completely separate implementation, not just read back by the same tools that wrote them.
Test dependencies
Running tests
The test runner exercises every public method against real DICOM files:
- Tag reads are cross-validated against pydicom
- Tag writes are confirmed by both PHP re-read and pydicom
- JPEG conversions are validated with Pillow (magic bytes, full decode, dimension matching)
- Compress/uncompress cycles verify transfer syntax changes, demographic preservation, and pixel data integrity
- Network operations run against a pynetdicom SCP that confirms C-ECHO events server-side and validates C-STORE round-trips down to pixel-level array equality
API reference
Classes
| Class | Purpose |
|---|---|
dicom_tag |
Read and write DICOM tags via dcmdump/dcmodify |
dicom_convert |
Image format conversion, compression, thumbnails |
dicom_net |
DICOM networking: C-ECHO, C-STORE SCU/SCP |
Standalone functions
| Function | Purpose |
|---|---|
is_dcm($file) |
Returns 1 if the file is valid DICOM, 0 otherwise |
Execute($command) |
Shell execution wrapper (captures stdout + stderr) |
Examples
The examples/ directory contains working scripts for common operations:
| File | Description |
|---|---|
get_tags.php |
Read and display tags from a DICOM file |
get_tags_webbased.php |
Same, formatted for browser output |
write_tags.php |
Modify tags in a DICOM file |
dcm_to_jpg.php |
Convert DICOM to JPEG |
jpg_to_dcm.php |
Convert JPEG to DICOM with custom tags |
jpg_to_dcm.xml |
XML template for JPEG-to-DICOM conversion |
compress.php |
JPEG lossless compress a DICOM file |
uncompress.php |
Decompress a DICOM file |
send_dcm.php |
Send a DICOM file to a remote host |
send_directory.php |
Send all files in a directory |
store_server.php |
Start a DICOM receive server |
store_server_handler.php |
Handler script called after each received file |
store_server_config.cfg |
Configuration for the receive server |
License
MIT