feat(images): zoom into the full resolution of a picture - #88
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #88 +/- ##
==========================================
+ Coverage 89.59% 89.74% +0.14%
==========================================
Files 39 39
Lines 2855 2954 +99
Branches 599 635 +36
==========================================
+ Hits 2558 2651 +93
- Misses 290 295 +5
- Partials 7 8 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The viewer shows a preview sized to the screen, and capped the zoom at five times it, so zooming in only ever enlarged its pixels: a tall comic fitted to the viewer could not be read at all. The first zoom now fetches the largest preview the server renders, decodes it in the background and swaps it in at the size the picture is drawn at, and lets the zoom go until one of its pixels is four on screen, never less than the five times it always allowed. Zooming goes on while it loads. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
skjnldsv
force-pushed
the
feat/zoom-native-resolution
branch
from
October 2, 2026 05:53
0309bf9 to
2bc70a3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tall pictures like comics could not be zoomed into far enough to read them.
Fixes nextcloud/viewer#2391
The zoom stopped at 5x, but raising that alone would not have helped: the viewer shows a preview sized to the screen (
previewSizeinpreviewUtils.ts), so past 1x it only enlarges the preview's pixels. For a tall picture that preview is tiny. An 800×10000 comic fitted to a 900 px high viewer comes as a preview about 72 px wide.The first zoom (wheel, pinch or double click) now fetches the largest preview the server renders, asking for 8192 px. The server never renders past the original nor past its own
preview_max_x/preview_max_y(4096 by default), so what comes back is as much detail as there is. Zooming goes on while it loads, up to the old 5x. It is loaded and decoded in the background (image.decode()), so a large picture does not stall a frame or two when it is swapped in, then swapped in place: same zoom, same pan, at the size the picture is already drawn at (refitting from its own size could round it a pixel off), and without a secondloadedfor the viewer. The zoom limit then follows that preview: up to 4 screen pixels per pixel of it, and never less than the 5x it always allowed. A preview no sharper than the one shown is not swapped in.Choices worth a look:
x-nc-previewheader, like its first preview (fix(preview): show previews on shares that forbid downloading #51).previewUrl) fetches nothing more; its zoom limit follows its own resolution.Unit tests cover the fetch on the first zoom only, the swap keeping the drawn size,
preloadImageanswering only once decoded, the limit following the detail (16x for 4000 px shown 1000 wide), 5x for a picture already shown in full, a failed fetch keeping the picture, the restricted share path and no fetch for a file shown as is; the three behaviour ones fail onmain. Not tried in a browser against a real server: the playground has no preview endpoint that renders sizes.👾 This pull request was assisted by Claude Code, commits carry an
Assisted-bytrailer.