| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- header('Content-Type:text/xml');
- ?>
- <?php
- define("DIR_DICOM_FS", getcwd() . "/");
-
- $rest = array();
-
- $pixelspacingX = 0;
- $pixelspacingY = 0;
- $physicalDeltaX = 0;
- $physicalDeltaY = 0;
-
- $filename = $_GET["filename"] ;
-
- $fname = DIR_DICOM_FS."upload/".$filename;
- $fname = str_replace("'","_",$fname);
-
- require_once(DIR_DICOM_FS."DICOM.php");
- $dicom = new File_DICOM();
-
- $isDicom = $dicom->isDicom($fname);
- if (!$isDicom)
- {
- echo "File is not DICOM. Please try again";
- exit();
- }
-
- $res = $dicom->parse($fname);
-
- if (isset($dicom->_elements[0x7FE0][0x0010]))
- {
- // Récupère les tags Dicom qui nous intéressent
- if (isset($dicom->_elements[0x0018][0x602c]))
- {
- $physicalDeltaX = $dicom->_elements[0x0018][0x602c][0]->value;
- }
-
- if (isset($dicom->_elements[0x0018][0x602e]))
- {
- $physicalDeltaY = $dicom->_elements[0x0018][0x602e][0]->value;
- }
-
- if (isset($dicom->_elements[0x0028][0x0030]))
- {
- $pixelspacingX = $dicom->_elements[0x0028][0x0030][0]->value;
- }
-
- if (isset($dicom->_elements[0x0028][0x0030]))
- {
- $pixelspacingY = $dicom->_elements[0x0028][0x0030][1]->value;
- }
- // Return the resource image alone
- $images = $dicom->imagecreatefromDICOM($fname);
-
- if (!empty($images))
- {
- foreach ($images as $im)
- {
- // Cryptage de l'image
- header("Content-type:image/jpeg");
-
- $dimh = imagesx($im);
- $dimv = imagesy($im);
-
- $ncol = ($dimv * 12) / 100;
-
- $red = 0;
- $green = 0;
- $blue = 0;
- $background = imagecolorallocate($im, $red, $green, $blue);
- $white = imagecolorallocate($im, 255, 255, 255);
-
- ImageFilledRectangle($im, 0, 0, $dimh, $ncol, $background);
- ImageFilledRectangle($im, 0, ($dimv - $ncol), $dimh, $dimv, $background);
-
- $idpatient = $_GET{'idpatient'};
- $lastname = $_GET{'lastname'};
- $firstname = $_GET{'firstname'};
- $sex = $_GET{'sex'};
- $birthdate = $_GET{'birthdate'};
-
- $text_h = $dimv - imagefontheight(12) - 20;
- $text_v = 20;
- imagestring($im, 12, $text_v, $text_h, $lastname.' '.$firstname.' '.$birthdate.' ('.$sex.') '.$idpatient, $white);
-
- // Enregistrement de l'image
- imagejpeg($im, $fname.".jpg", 100);
-
- imagejpeg($im, $fname.".jpg");
- chmod($fname.".jpg", 0755);
- imagedestroy($im);
- }
- }
- }
-
- // on retourne les Tags
- print($filename);
- print('_TAG_');
- print ($physicalDeltaX);
- print('_TAG_');
- print ($physicalDeltaY);
- print('_TAG_');
- print ($pixelspacingX);
- print('_TAG_');
- print ($pixelspacingY);
- print('_TAG_');
- ?>
|