Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better thumbnail image scaling #5610

Merged
merged 1 commit into from
Jan 23, 2015

Conversation

fkaelberer
Copy link
Contributor

ctx.drawImage() does a bad job scaling large image onto a small canvas (results are very noisy/blocky). Therefore, images are scaled down by factor 2 several times before the image is scaled to thumbnail canvas size.

This PR changes the order of scaling factors: It first scales by a fractional value, and then scales down by 2 several times. Scaling by fractional numbers usually introduces more artifacts (e.g. blurryness) than scaling by powers of 2. The resulting image quality is higher because the artifacts of fractional scaling are introduced in the first scaling step, and then than vanish when downsampling by exact powers of 2 afterwards.

The following animated gif toggles the thumbnail images which are generated with new and old code from the tracemonkey paper at 70%, 100%, 180% and 300% zoom.
output_ghu1jf

@timvandermeij
Copy link
Contributor

@fkaelberer That looks much better than before! I have only found that it isn't applied to all thumbnails, but mostly only for the currently active page and maybe the next one. See the screenshot I took below. You can see that the first two are very nice, but the other two are rather dark. If I go to one of the pages with a dark thumbnail and reload the viewer, then that thumbnail is nice and the other ones are darker. Any idea what causes that?

naamloos

@Snuffleupagus
Copy link
Collaborator

@timvandermeij That issue is already present in master. The difference should be that the first two thumbnails are created using the page canvas, while the others are actually rendered.

@yurydelendik
Copy link
Contributor

That issue is already present in master. The difference should be that the first two thumbnails are created using the page canvas, while the others are actually rendered.

Correct, in the future we can try rendering on the canvas 2x larger and scale down to the target size.

@timvandermeij
Copy link
Contributor

In that case ignore my comment. Sorry for the noise!

@CodingFabian
Copy link
Contributor

this can be merged right? The thumbnail looks indeed better and the PR does not change anything besides the manual downscaling order.

@timvandermeij
Copy link
Contributor

Some thumbnail regressions have been found. See #5637 for all details. While this PR does not have anything to do with those, it magically fixes one of them (the stretching issue). We're not yet sure why (or why the other two commits caused the regressions in the first place).

@timvandermeij
Copy link
Contributor

Regressions have been fixed.

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/0360358bbda8c19/output.txt

timvandermeij added a commit that referenced this pull request Jan 23, 2015
@timvandermeij timvandermeij merged commit 6f36df7 into mozilla:master Jan 23, 2015
@timvandermeij
Copy link
Contributor

Really nice, thank you!

speedplane pushed a commit to speedplane/pdf.js that referenced this pull request Feb 24, 2015
@fkaelberer fkaelberer deleted the betterThumbnailScaling branch March 20, 2015 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants