Example #1
0
 /**
  * Extract metadata from JP2 image file's XML header
  *
  * @param string $image_filepath Full path to JP2 image file
  *
  * @return array A subset of the information stored in the jp2 header
  */
 public function extractJP2MetaInfo($image_filepath)
 {
     include_once HV_ROOT_DIR . '/../src/Image/JPEG2000/JP2ImageXMLBox.php';
     try {
         $xmlBox = new Image_JPEG2000_JP2ImageXMLBox($image_filepath);
         $dimensions = $xmlBox->getImageDimensions();
         $refPixel = $xmlBox->getRefPixelCoords();
         $imageScale = (double) $xmlBox->getImagePlateScale();
         $dsun = (double) $xmlBox->getDSun();
         $sunCenterOffsetParams = $xmlBox->getSunCenterOffsetParams();
         $layeringOrder = $xmlBox->getLayeringOrder();
         // Normalize image scale
         $imageScale = $imageScale * ($dsun / HV_CONSTANT_AU);
         $meta = array("scale" => $imageScale, "width" => (int) $dimensions[0], "height" => (int) $dimensions[1], "refPixelX" => (double) $refPixel[0], "refPixelY" => (double) $refPixel[1], "sunCenterOffsetParams" => $sunCenterOffsetParams, "layeringOrder" => $layeringOrder);
     } catch (Exception $e) {
         throw new Exception(sprintf("Unable to process XML Header for %s: %s", $image_filepath, $e->getMessage()), 13);
     }
     return $meta;
 }
Example #2
0
 /**
  * NOTE: Add option to specify XML vs. JSON... FITS vs. Entire header?
  *
  * @return void
  */
 public function getJP2Header()
 {
     include_once HV_ROOT_DIR . '/../src/Database/ImgIndex.php';
     include_once HV_ROOT_DIR . '/../src/Image/JPEG2000/JP2ImageXMLBox.php';
     $imgIndex = new Database_ImgIndex();
     $image = $imgIndex->getImageInformation($this->_params['id']);
     $filepath = HV_JP2_DIR . $image['filepath'] . '/' . $image['filename'];
     $xmlBox = new Image_JPEG2000_JP2ImageXMLBox($filepath, 'meta');
     if (isset($this->_params['callback'])) {
         $this->_printJSON($xmlBox->getXMLString(), true);
     } else {
         $xmlBox->printXMLBox();
     }
 }