21 public function __invoke(Request $request, Response $response, $args)
23 $path = base64_decode($request->getAttribute(
'path'));
24 $page = (int)$request->getAttribute(
'page');
25 $resolution = (int)$request->getAttribute(
'resolution');
28 if ($resolution == 0) {
33 $document_hash = (
new Document($path))->hash;
34 $thumbnail_path =
'static/img/cache/' . $document_hash .
'[' . $page .
'][' . $resolution .
'].jpg';
37 if (file_exists($thumbnail_path)) {
38 $cached_thumbnail_response = $response->withHeader(
'Content-type',
'image/jpeg');
39 readfile($thumbnail_path);
40 return $cached_thumbnail_response;
45 $im->setResolution($resolution, $resolution);
46 $im->readImage($path .
'[' . $page .
']');
47 $im->setImageFormat(
'jpg');
48 $im->writeImage($thumbnail_path);
51 $thumbnail_response = $response->withHeader(
'Content-type',
'image/jpeg');
57 return $thumbnail_response;
__construct(LoggerInterface $logger)
__invoke(Request $request, Response $response, $args)