PHP code example of aurabx / dcmtk-php

1. Go to this page and download the library: Download aurabx/dcmtk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aurabx / dcmtk-php example snippets


use Aurabx\Dcmtkphp\Config;

Config::set('dcmtk-path', '/custom/path/to/dcmtk');

use Aurabx\Dcmtkphp\Tag;

$tag = new Tag();
$tag->setFilePath('/path/to/image.dcm');

// Get specific tags
$patientName = $tag->getTag('0010', '0010');  // Patient Name
$modality = $tag->getTag('0008', '0060');     // Modality
$studyDate = $tag->getTag('0008', '0020');    // Study Date

// Access all tags
$allTags = $tag->tags;

use Aurabx\Dcmtkphp\Tag;

$tag = new Tag();
$tag->setFilePath('/path/to/image.dcm');

$tag->writeTags([
    '0010,0010' => 'DOE^JOHN',      // Patient Name
    '0010,0020' => '12345',          // Patient ID
    '0008,0080' => 'Hospital Name',  // Institution Name
]);

use Aurabx\Dcmtkphp\Convert;

$convert = new Convert();
$convert->file = '/path/to/image.dcm';
$convert->jpg_quality = 90;  // 0-100

$jpegPath = $convert->dcmToJpg();

use Aurabx\Dcmtkphp\Convert;

$convert = new Convert();
$convert->file = '/path/to/image.dcm';
$convert->tn_size = 150;  // Width in pixels

$thumbnailPath = $convert->dcmToThumbnail();

use Aurabx\Dcmtkphp\Convert;

$convert = new Convert();
$convert->file = '/path/to/image.dcm';

// Decompress JPEG-compressed DICOM
$convert->uncompress();

// Compress to JPEG lossless
$convert->compressToJpeg();

use Aurabx\Dcmtkphp\Net;

$net = new Net();
$result = $net->echoscu('pacs.hospital.com', 104, 'MY_AE_TITLE', 'REMOTE_AE');

use Aurabx\Dcmtkphp\Net;

$net = new Net();
$net->setFilePath('/path/to/image.dcm');

// Send single file
$net->sendDcm('pacs.hospital.com', 104, 'MY_AE', 'REMOTE_AE');

// Send all files in directory
$net->sendDcm('pacs.hospital.com', 104, 'MY_AE', 'REMOTE_AE', true);

use Aurabx\Dcmtkphp\Net;

$net = new Net();
$net->storeServer(
    dcm_dir: '/path/to/storage',
    ae_name: 'MY_PACS',
    port: 104
);

use Aurabx\Dcmtkphp\DcmtkPhp;

$dcmtk = new DcmtkPhp();
$isDicom = $dcmtk->isDicom('/path/to/file');
bash
composer