1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 06:38:07 +02:00

Merge pull request #19621 from Snuffleupagus/bug-1943094-thumbs

Limit the maximum thumbnail canvas width/height, similar to pages (PR 19604 follow-up)
This commit is contained in:
Jonas Jenwald 2025-03-10 11:32:08 +01:00 committed by GitHub
commit 1bc98dfbd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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]