/** * Find the best match for a single JPEG2000 image and either * output a link to the image, or display the image directly. * * @return void */ public function getJP2Image() { include_once HV_ROOT_DIR . '/../src/Database/ImgIndex.php'; $imgIndex = new Database_ImgIndex(); // Optional parameters $defaults = array('jpip' => false, 'json' => false); $options = array_replace($defaults, $this->_options); // If image id is set, use it if (isset($this->_params['id'])) { $filepath = HV_JP2_DIR . $imgIndex->getDataFilePathFromId($this->_params['id']); } else { // Filepath to JP2 Image $filepath = HV_JP2_DIR . $imgIndex->getDataFilePath($this->_params['date'], $this->_params['sourceId']); } // Output results if ($options['jpip']) { if ($options['json']) { header('Content-type: application/json;charset=UTF-8'); echo json_encode(array('uri' => $this->_getJPIPURL($filepath))); } else { echo $this->_getJPIPURL($filepath); } } else { $this->_displayJP2($filepath); } }