/** * Test image properties * * @return void */ public function testImageProperties() { $picture = new Viewer\Picture($this->_conf, $this->_series->getRepresentative(), null); $width = $picture->getWidth(); $height = $picture->getHeight(); $isPyramidal = $picture->isPyramidal(); $fpath = $picture->getFullPath(); $vformats = $picture->getVisibleFormats(); $url = $picture->getUrl(null); $surl = $picture->getUrl(null, 'default'); $name = $picture->getName(); $this->integer($width)->isEqualTo(150); $this->integer($height)->isEqualTo(200); $this->boolean($isPyramidal)->isFalse(); $this->string($fpath)->isIdenticalTo($this->_roots[0] . '/doms.jpg'); $this->string($name)->isIdenticalTo('doms.jpg'); $this->array($vformats)->hasSize(1); $this->string($url)->isIdenticalTo('/show/default/doms.jpg'); $this->string($surl)->isIdenticalTo('/show/default/doms.jpg'); $picture = new Viewer\Picture($this->_conf, DEFAULT_PICTURE, null); $width = $picture->getWidth(); $height = $picture->getHeight(); $isPyramidal = $picture->isPyramidal(); $fpath = $picture->getFullPath(); $vformats = $picture->getVisibleFormats(); $url = $picture->getUrl(null); $surl = $picture->getUrl(null, 'default'); $name = $picture->getName(); $this->integer($width)->isEqualTo(3090); $this->integer($height)->isEqualTo(4277); $this->boolean($isPyramidal)->isFalse(); $this->string($fpath)->isIdenticalTo(WEB_DIR . '/images/' . DEFAULT_PICTURE); $this->string($name)->isIdenticalTo(DEFAULT_PICTURE); $this->array($vformats)->hasSize(3); $this->string($url)->isIdenticalTo('/show/default/main.jpg'); $this->string($surl)->isIdenticalTo('/show/default/main.jpg'); }
$app->get('/ajax/img(/:series)/:image(/format/:format)', function ($series_path = null, $image, $format = 'default') use($app, $viewer) { $picture = $viewer->getImage($series_path, $image); $display = $picture->getDisplay($format); $response = $app->response(); foreach ($display['headers'] as $key => $header) { $response[$key] = $header; } $response->body($display['content']); }); $app->get('/ajax/representative/:series/format/:format', function ($series_path = null, $format) use($app, $conf, $app_base_url) { $request = $app->request; $start = $request->params('s'); $end = $request->params('e'); $series = new Series($conf, $series_path, $app_base_url, $start, $end); $picture = new Picture($conf, $series->getRepresentative(), $app_base_url, $series->getFullPath()); $app->redirect($picture->getUrl($series, $format)); }); $app->get('/ajax/series/infos/:series/:image', function ($series_path, $img) use($app, $conf, $app_base_url) { $request = $app->request; $start = $request->params('s'); $end = $request->params('e'); $series = new Series($conf, $series_path, $app_base_url, $start, $end); if ($img !== null) { $series->setImage($img); } $infos = $series->getInfos(); echo json_encode($infos); }); $app->get('/ajax/image/infos/:image_params+', function ($img_params) use($app, $conf) { $img = array_pop($img_params); $path = null;