Ejemplo n.º 1
0
 /**
  * Creates Deep Zoom image from source file and saves it to destination
  *
  * @param string $source
  * @param string $destination
  */
 public function create($source, $destination)
 {
     $this->_image = new Thumbnail($source);
     list($width, $height) = $this->_image->size();
     $this->_descriptor = new Oz_Deepzoom_Descriptor($width, $height, $this->_tileSize, $this->_tileOverlap, $this->_tileFormat);
     $aImage = pathinfo($destination);
     /**
      * @todo secure varaibles
      */
     $imageName = $aImage['filename'];
     $dirName = $aImage['dirname'];
     $imageFile = $this->_ensure($dirName . DIRECTORY_SEPARATOR . $imageName . '_files');
     foreach (range(9, $this->_descriptor->numLevels() - 1) as $level) {
         $levelDir = $this->_ensure($imageFile . DIRECTORY_SEPARATOR . $level);
         $levelImage = $this->getImage($level);
         $tiles = $this->tiles($level);
         $format = $this->_descriptor->tileFormat;
         foreach ($tiles as $_tile) {
             list($column, $row) = $_tile;
             list($x, $y, $x2, $y2) = $this->_descriptor->getTileBounds($level, $column, $row);
             $cropLevelImage = clone $levelImage;
             $cropLevelImage->crop($x, $y, $x2, $y2);
             $format = $this->_descriptor->tileFormat;
             $tilePath = $levelDir . DIRECTORY_SEPARATOR . sprintf('%s_%s.%s', $column, $row, $format);
             $cropLevelImage->save($tilePath);
             unset($cropLevelImage);
         }
         unset($levelImage);
     }
     $this->_descriptor->save($destination);
 }
Ejemplo n.º 2
0
 /**
  * Tests Oz_Deepzoom_Descriptor->getTileBounds()
  */
 public function testInvalidGetTileBounds()
 {
     try {
         $this->_descriptor->getTileBounds(-1, 0, 0);
     } catch (Oz_Deepzoom_Exception $e) {
         $this->assertTrue('Invalid pyramid level (TileBounds)' === $e->getMessage());
         return;
     }
     $this->fail();
     return;
 }