From 0fd2f12728e3eb0f198560ddfb2058370878c7a7 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sun, 28 May 2023 14:52:41 +0200 Subject: [PATCH] Don't downscale by steps images which will end up with small dimensions (bug 1445735) --- src/display/canvas.js | 10 ++++++++++ test/pdfs/bug1445735.pdf.link | 1 + test/test_manifest.json | 10 +++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/bug1445735.pdf.link diff --git a/src/display/canvas.js b/src/display/canvas.js index ba93deefcc9c7..36a0c86892aea 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -1188,6 +1188,16 @@ class CanvasGraphics { 1 ); + if (width / widthScale <= 5 && height / heightScale <= 5) { + // The final image is very small, hence having a poor quality + // when rescaling isn't really a problem. + return { + img, + paintWidth: width, + paintHeight: height, + }; + } + let paintWidth = width, paintHeight = height; let tmpCanvasId = "prescale1"; diff --git a/test/pdfs/bug1445735.pdf.link b/test/pdfs/bug1445735.pdf.link new file mode 100644 index 0000000000000..de8f83e76816e --- /dev/null +++ b/test/pdfs/bug1445735.pdf.link @@ -0,0 +1 @@ +https://bugzilla.mozilla.org/attachment.cgi?id=8958936 diff --git a/test/test_manifest.json b/test/test_manifest.json index 4d4bb76d063e3..8851a57eb9aa6 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -7713,5 +7713,13 @@ "value": ["Three", "Five"] } } - } + }, + { + "id": "bug1445735", + "file": "pdfs/bug1445735.pdf", + "md5": "a5470d82c1d23eac1fef2fa37f95e980", + "rounds": 1, + "link": true, + "type": "eq" + } ]