Wednesday, May 7, 2014

Calling DCMTK commands like DCM2PNM from PHP

When a command is called from PHP via the exec command, it runs with the user environment of the Apache/nginx host process (e.g. www, http, wwwrun).

As some of the DCMTK commands rely on the DCMDICTPATH variable, they may fail as this is normally not set for the www user.

You can overcome this by adding
putenv("DCMDICTPATH=/usr/share/dicom.dic:/usr/share/diconde.dic:/usr/share/private.dic");
to the beginning of your PHP script / before calling the respective DCMTK command.

Notice: You may have to adjust the paths according to your installation of DCMTK.


No comments:

Post a Comment