From e3be85e24011ce42b9c48e19a21b9e7faba72767 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 24 Oct 2019 06:58:04 +0200 Subject: [PATCH 1/1] foto: keep static images of height 250 Drop dynamic source replacement to match actual client sizes, as the quality loss from downsizing a _larger_ image is minimal. Originally introduced in lijtweg commit v2.5-7-gcd93e774e6 (2017-10-11) [foto: replace justified thumbnails by height-optimised versions] with visible improvements probably due to using the target size of 200px without adjusting for up to 1.25x enlargement to fit. Testing originals of 250px on modern browsers with (bilinear) rescaling is hard to distinguish (not significantly more blurry) and depends on only a single thumbnail resolution to be created for significantly reduced resource requirements. May be slightly larger on average, but likely much smaller without reloads and considering caching opportunities. --- foto/album.inc.php | 15 --------------- foto/index.php | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/foto/album.inc.php b/foto/album.inc.php index 42061d7..7a3f917 100644 --- a/foto/album.inc.php +++ b/foto/album.inc.php @@ -74,7 +74,6 @@ function imgjustify() { targetRowHeight: 200, }; var layout = require('justified-layout')(ratios, config); - var thumbreplace = !/[?&]blur\b/.test(window.location.search); gallery.style.position = 'relative'; gallery.style.height = layout.containerHeight + 'px'; @@ -86,20 +85,6 @@ function imgjustify() { imgel.style.position = 'absolute'; imgel.style.top = layout.boxes[i].top + 'px'; imgel.style.left = layout.boxes[i].left + 'px'; - - if (thumbreplace) { - var thumbtarget = imgel.src.replace(/(\/thumb\/)\d+/, '$1'+layout.boxes[i].height) - if (imgel.complete) { - imgel.src = thumbtarget; - } - else if (thumbtarget != imgel.src) { - var loadthumb = new Image(); - loadthumb.src = thumbtarget; - loadthumb.onload = function() { - imgel.src = this.src; - }; - } - } })(); } }; diff --git a/foto/index.php b/foto/index.php index d3e9898..e9b9521 100644 --- a/foto/index.php +++ b/foto/index.php @@ -36,7 +36,7 @@ function showthumb($path) { // assume all album entries are symlinks to archive originals $target = preg_replace('{^(\.\./)*}', '', readlink($path)); - $thumb = 'thumb/200/' . $target; + $thumb = 'thumb/250/' . $target; @list ($order, $size, $title) = explode(':', pathinfo($path, PATHINFO_FILENAME), 3); $imgtag = 'img src="/'.$thumb.'"'; -- 2.30.0