예제 #1
0
 public function rotate()
 {
     $asset = $this->getItem();
     $length = $asset->length;
     $chunkSize = $asset->chunkSize;
     $chunks = ceil($length / $chunkSize);
     $collChunkName = $asset->collectionNameGridFS() . ".chunks";
     $collChunks = $asset->getDb()->{$collChunkName};
     $binImagedata = null;
     for ($i = 0; $i < $chunks; $i++) {
         $chunk = $collChunks->findOne(array("files_id" => $asset->_id, "n" => $i));
         $binImagedata .= $chunk["data"]->bin;
     }
     $dscImage = new \Dsc\Image(\imagecreatefromstring($binImagedata));
     $dscImage->rotate($this->app->get('PARAMS.degrees'), null, false);
     $buffer = $dscImage->toBuffer();
     $asset->replace($buffer);
     $this->app->reroute('/admin/asset/edit/' . $this->app->get('PARAMS.id'));
 }