Skip to content

Commit

Permalink
Merge pull request #19621 from Snuffleupagus/bug-1943094-thumbs
Browse files Browse the repository at this point in the history
Limit the maximum thumbnail canvas width/height, similar to pages (PR 19604 follow-up)
  • Loading branch information
Snuffleupagus authored Mar 10, 2025
2 parents 81baa16 + eef15a3 commit 1bc98df
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions web/pdf_thumbnail_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,21 @@ class PDFThumbnailView {
willReadFrequently: !enableHWA,
});
const outputScale = new OutputScale();
const width = upscaleFactor * this.canvasWidth,
height = upscaleFactor * this.canvasHeight;

canvas.width = (upscaleFactor * this.canvasWidth * outputScale.sx) | 0;
canvas.height = (upscaleFactor * this.canvasHeight * outputScale.sy) | 0;
if (this.maxCanvasDim !== -1) {
const maxScale = Math.min(
this.maxCanvasDim / width,
this.maxCanvasDim / height
);
if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
outputScale.sx = maxScale;
outputScale.sy = maxScale;
}
}
canvas.width = (width * outputScale.sx) | 0;
canvas.height = (height * outputScale.sy) | 0;

const transform = outputScale.scaled
? [outputScale.sx, 0, 0, outputScale.sy, 0, 0]
Expand Down

0 comments on commit 1bc98df

Please sign in to comment.