예제 #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'));
 }
예제 #2
0
//set last-modified header
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastModified) . " GMT");
//set etag-header
header("Etag: {$etagFile}");
//make sure caching is turned on
header('Cache-Control: public');
// set content type header
header('Content-type: ' . $item->get('contentType'));
//check if page has changed. If not, send 304 and exit
if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified || $etagHeader == $etagFile) {
    header("HTTP/1.1 304 Not Modified");
    exit;
}
// display the binary data
$length = $item->get("length");
$chunkSize = $item->get("chunkSize");
$chunks = ceil($length / $chunkSize);
$collChunkName = $model->collectionNameGridFS() . ".chunks";
$collChunks = $model->getDb()->{$collChunkName};
$binImagedata = null;
for ($i = 0; $i < $chunks; $i++) {
    $chunk = $collChunks->findOne(array("files_id" => $item->_id, "n" => $i));
    $binImagedata .= $chunk["data"]->bin;
}
if (!empty($height) && !empty($width)) {
    $img = new \Dsc\Image(imagecreatefromstring($binImagedata));
    $img->resize($width, $height, false);
    echo $img->toBuffer();
} else {
    echo $binImagedata;
}