PHP DICOM Class

Third-party non-commercial applications based on the DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
vedicveko
Posts: 4
Joined: Fri, 2011-04-08, 16:14

PHP DICOM Class

#1 Post by vedicveko »

class_dicom.php is a PHP class that lets you work with DICOM files within PHP programs. class_dicom.php enables you to retrieve tags, write tags, convert to JPEG, make thumbnails, convert JPEG to DICOM, compress DICOM, uncompress DICOM, receive DICOM files over the network, and send DICOM files over the network. It even comes with several example programs so you can get started writing your own code right away!

class_dicom.php relies on the OFFIS DICOM Toolkit.

My aim was to keep the interface as simple as possible while at the same time providing a class that would be easy to grow.

You can get a copy, along with documentation at: http://www.deanvaughan.org/projects/class_dicom_php/

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

Thanks for using DCMTK for your project and for you posting in this forum :-)

Btw, I just browsed trough your main PHP file: There's no need to distinguish between JPEG-compressed and uncompressed DICOM images; you can always use "dcmj2pnm" in order to create JPEG output images. This also avoids the use of ImageMagick's "convert" for the conversion from TIFF to JPEG. Furthermore, dcm2pnm/dcmj2pnm allow for scaling the output image, e.g. in order to create icons/thumbnails.

For the storescp call in debug mode, you should probably better use "-v -d" instead of "-d -v" because in DCMTK 3.6.0 verbose (INFO) and debug (DEBUG) mode are mutually exclusive and the righter most option "wins" - the latter was already the case in previous DCMTK versions.

vedicveko
Posts: 4
Joined: Fri, 2011-04-08, 16:14

#3 Post by vedicveko »

Jörg Riesmeier wrote: Awesome suggestions
Wow, thanks!

I've implemented your suggestions, they certainly lead to simpler code!

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#4 Post by Jörg Riesmeier »

That was fast :-) Two short comments on the new version:

Code: Select all

    $jpg_quality = 95;

    $this->jpg_file = $this->file . '.jpg';
    $this->tiff_file = $this->file . '.tiff';
   
    if(!$this->transfer_syntax) {
      $tags = new dicom_tag;
      $tags->file = $this->file;
      $tags->load_tags();
      $this->transfer_syntax = $tags->get_tag('0002', '0010');
    }

    if(strstr($this->transfer_syntax, 'Baseline') || strstr($this->transfer_syntax, 'Lossless')) {
      $jpg_quality = 100;
    }
I guess the TIFF filename is not needed any longer, right?

Also, I don't think that a JPEG quality of 95% or even 100% is really useful. Shouldn't 90% be sufficient? And, what's also interesting: For uncompressed images you are now using a quality of 95%, while you are using 100% for JPEG-Lossless and JPEG-Baseline (8-bit lossy). Or did I misinterpret you code?

vedicveko
Posts: 4
Joined: Fri, 2011-04-08, 16:14

#5 Post by vedicveko »

I was about halfway through typing up a reply about how it makes sense to me, but then I realized it's just my opinion and it didn't have much bearing on anything.

I've changed the JPEG quality to be a value you can set on the class. It defaults to 100, but you can always change it to whatever you would like it to be.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest