-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Fixes drawImage for thumbs #4924
Conversation
/botio-windows preview |
From: Bot.io (Windows)ReceivedCommand cmd_preview from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/7b5522c37e61563/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/7b5522c37e61563/output.txt Total script time: 0.96 mins Published
|
This looks a lot better, yes. I agree that making it even better might not be useful because indeed users do not need to read it. It would only affect performance to make it even better. |
Fixes #2888 |
@@ -1260,6 +1260,8 @@ var PDFView = { | |||
} | |||
} | |||
this.pdfDocument.cleanup(); | |||
|
|||
ThumbnailView.tempImageCache = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either this, or the last line in thumbnail_view.js looks like a duplicate for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first one initializes, second one cleans up
the quality looks now comparable between the two ways the thumb can be generated. I still believe i can see a difference, but maybe thats only because i have looked at them for a day. I was looking into ways without writing our own resampling algorithm. But because thats what you have done here, let me at least post this SO question containing alternative resizing implementations. Maybe it should be refactored out, so it can be benchmarked and optimised separately. |
@CodingFabian we have couple of resizing algorithms e.g. in image.js, but we shall not perform any of those for 1) memory consumption, 2) or, block the main thread by JS code execution |
This looks great! |
Bad idea from memory consumption point of view and drawing on large canvas is slower than on smaller |
Also, getting the raw pixel data messes with hardware acceleration of the canvas (not counting on amount of memory you will be allocating) and makes the canvas operations even slower. |
var reducedHeight = img.height; | ||
|
||
// drawImage does an awful job of rescaling the image, doing it gradually | ||
var MAX_SCALE_FACTOR = 2.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could use 4 as max scale factor.
the while loop will trigger when for example the needed scale is 2.1, which will downscale to 1.1 which then the final draw will make to 1.0.
by using a scale like 4, the last draw Image call will get some more downscaling to do, effectively cutting down one loop with little noticeable effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 is used for a reason to avoid loosing any pixel information, which is important for text or thin lines.
in my benchmarks, this is about 2-3 times better than the old code on chrome, which surprises me. but it seems that most scale down is now done in GPU memory. The thumbnail quality looks good for me. i would merge it like this. |
Fixes drawImage for thumbs
Fixes #4921
And don't think we need to worry fixing #2888 as well, thumbnails just to quickly locate the page and not read it.