<?php error_reporting(0); if (isset($_REQUEST['width']) && $_REQUEST['width'] != '') { $width = $_REQUEST['width']; } if (isset($_REQUEST['height']) && $_REQUEST['height'] != '') { $height = $_REQUEST['height']; } if ($height != '') { header('Content-Type: image/jpeg'); include 'resizeimageclass.php'; $image = new ResizeImage(); $image->load($_REQUEST['path']); $image->resizeToHeight($height); $image->output(); } if ($width != '') { header('Content-Type: image/jpeg'); include 'resizeimageclass.php'; $image = new ResizeImage(); $image->load($_REQUEST['path']); $image->resizeToWidth($width); $image->output(); } // header('Content-Type: image/jpeg'); // include('resizeimageclass.php'); // $image = new ResizeImage (); // $image->load($_REQUEST['path']); // $image->resizeToWidth($width); // $image->output();
function _makeThumbnail($height, $width, $personId) { $person = new Person(); $person->personId = $personId; $person->populate(); $picFile = ''; if ($person->activePhoto > 0) { $attachmentId = $person->activePhoto; $attachment = new Attachment(); $attachment->attachmentId = $attachmentId; $attachment->populate(); $db = Zend_Registry::get('dbAdapter'); $sql = "select data from attachmentBlobs where attachmentId = " . $attachmentId; $stmt = $db->query($sql); $row = $stmt->fetch(); $picFile = tempnam('/tmp', 'patpic'); file_put_contents($picFile, $row['data']); $stmt->closeCursor(); } else { $patientDir = Zend_Registry::get('config')->document->legacyStorePath . '/' . $personId; if ($personId == 0 || !file_exists($patientDir)) { $this->noPictureAction(); } $dir = dir($patientDir); $picturePath = array(); while (false !== ($entry = $dir->read())) { if (preg_match('/.*_pat_pic([0-9]+.*).jpg/', $entry, $matches)) { $timestamp = strtotime($matches[1]); if (!isset($picturePath['timestamp']) || isset($picturePath['timestamp']) && $timestamp > $picturePath['timestamp']) { $picturePath['timestamp'] = $timestamp; $picturePath['path'] = $patientDir . '/' . $entry; } } } $picFile = $picturePath['path']; } if (!file_exists($picFile)) { $this->noPictureAction(); } $patientPicture = new ResizeImage(); $patientPicture->load($picFile); $patientPicture->resize((int) $width, (int) $height); return $patientPicture; }