if ($this->backgroundsPrefix == 'p') {
$srcPrefix = 'h';
}
+ $thumbs = array();
foreach ($this->pages as $page => $infos) {
if ($this->svg) {
$orig = wsDocument::getDir($infos['document_id']) . 'html/p' . $infos['document_page'] . '.svg';
$thumb = wsDocument::getDir($infos['document_id']) . 'p' . $infos['document_page'] . '.jpg';
}
-
- $this->copy($thumb, $this->vdir . '/data/thumbnails/p' . $page . '.jpg');
+ $thumbs[$page] = $thumb;
if ($page == 1) {
$this->_makeCover(wsDocument::getDir($infos['document_id']) . 'html/t36-' . $infos['document_page'] . '.jpg');
}
}
- $this->makeThumbSprites();
+ $this->makeThumbSprites($thumbs);
}
- public function makeThumbSprites() {
+ public function makeThumbSprites(array $thumbs) {
$cols = 10;
$rows = 10;
$perSprite = $cols * $rows;
$k = 0;
$res = '';
- $pages = count($this->pages);
+ $pages = count($thumbs);
+ $hash = '';
for ($i = 1; $i <= $pages; $i += $perSprite) {
$num = min(1 + $pages - $i, $perSprite);
$srows = ceil($num / $cols);
$files = array();
+ $mtime = 0;
for ($j = 0; $j < $perSprite; $j++) {
$p = $i + $j;
if ($p > $pages) {
break;
}
- $files[] = $this->vdir . '/data/thumbnails/p' . $p . '.jpg';
+ $files[] = $thumbs[$p];
+ $hash .= $thumbs[$p] . '--' . filemtime($thumbs[$p]);
+ }
+
+ $cache = WS_CACHE . '/thumbsprites/' . hash('sha256', $hash) . '.jpg';
+ $dest = $this->vdir . '/data/thumbnails/s' . $k . '.jpg';
+ if (!file_exists($cache)) {
+ $cmd = 'montage ' . implode(' ', $files) . ' -geometry 100x+0+0 -background transparent -tile ' . $cols . 'x' . $srows . ' ' . $cache;
}
- $cmd = 'montage ' . implode(' ', $files) . ' -geometry 100x+0+0 -background transparent -tile ' . $cols . 'x' . $srows . ' ' . $this->vdir . '/data/thumbnails/s' . $k . '.jpg';
+ copy($cache, $dest);
$res .= `$cmd`;
$k++;
}
$res[] = '.landscape #shadow>div.right{left: ' . $w . ';}';
$res[] = '.landscape .page.right{left:' . $w . '}';
if ($this->theme->parametres->displayPageNumber) {
- $res[] = '#pagesnumbers{font-size: ' . (13 * $this->z) . 'px;margin: ' . (5 * $this->z) . 'px 0 0 0;top:' . $h . ';color:' . wsHTML5::colorToCSS($this->theme->parametres->colorPageNumber) . '}';
+ $res[] = '#pagesnumbers{font-size: ' . (11 * $this->z) . 'px;margin: ' . (5 * $this->z) . 'px 0 0 0;top:' . $h . ';color:' . wsHTML5::colorToCSS($this->theme->parametres->colorPageNumber) . '}';
$res[] = '#pagesnumbers div{width:' . $w . '}';
} else {
$res[] = '#pagesnumbers{display:none;}';