コード例 #1
0
ファイル: ImageCreator.php プロジェクト: GruppoMeta/Movio
 /**
  * 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);
 }
コード例 #2
0
 /**
  * Tests Oz_Deepzoom_Descriptor->numLevels()
  */
 public function testNumLevels()
 {
     $levels = $this->_descriptor->numLevels();
     $this->assertGreaterThan(0, $levels);
 }