From 5b50a5055932b70de33b18e6d68d73ad024d8e87 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 31 Jul 2022 13:59:37 +0200 Subject: [PATCH] Ignore too small page-canvases in `PDFThumbnailView.setImage` It doesn't make sense to use a page-canvas that's *smaller* than the resulting thumbnail, since that causes the image to be upscaled which results in a blurry thumbnail. Note that this doesn't normally happen, unless a very small zoom-level is used in the viewer. --- web/pdf_thumbnail_view.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js index 2cf3f6c5c..c990cc467 100644 --- a/web/pdf_thumbnail_view.js +++ b/web/pdf_thumbnail_view.js @@ -352,13 +352,17 @@ class PDFThumbnailView { if (this.renderingState !== RenderingStates.INITIAL) { return; } - const { thumbnailCanvas: canvas, pdfPage } = pageView; + const { thumbnailCanvas: canvas, pdfPage, scale } = pageView; if (!canvas) { return; } if (!this.pdfPage) { this.setPdfPage(pdfPage); } + if (scale < this.scale) { + // Avoid upscaling the image, since that makes the thumbnail look blurry. + return; + } this.renderingState = RenderingStates.FINISHED; this._convertCanvasToImage(canvas); }