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
Type3 smoothing: pre-scale image in the paintImageMaskXObject #1763
Conversation
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.21.233.14:8877/15cf34772c57a0e/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/fcfc284af1d6dd0/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/fcfc284af1d6dd0/output.txt Total script time: 13.90 mins
Image differences available at: http://107.22.172.223:8877/fcfc284af1d6dd0/reftest-analyzer.xhtml#web=eq.log |
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/15cf34772c57a0e/output.txt Total script time: 19.76 mins
Image differences available at: http://107.21.233.14:8877/15cf34772c57a0e/reftest-analyzer.xhtml#web=eq.log |
@@ -1094,6 +1094,40 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { | |||
} | |||
} | |||
} | |||
function rescaleImage(pixels, widthScale, heightScale) { |
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.
We have a resize in image.js too. Do we want to try and share code between the two?
https://github.com/mozilla/pdf.js/blob/master/src/image.js#L131
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.
This is specialized algorithm is addressed only this specific problem. The algorithm in the image.js does not take in account pixels "in between" steps of copy operation, this does. Which gives you this smoothing effect. Also, I don't this we have to use this (in canvas.js) algorithm in some other place.
Ref tests seem mostly good, however issue1597-page1 seems to have some new line artifacts(but not on crhome windows) and fit11-talk seems to be much darker (this one could be fine). P.S. That's a nice big fix list. |
Also, is the real issue that we're scaling multiple times whereas we should be scaling once to the actual output size? I thought FF by default did a bicubic rescale which should give much better/faster results than we can get in JS. |
Bicubic is good for up-scaling. In this case it's down-scaling and pieces/pixels (mostly alpha layer values) are lost during the resizing using standard canvas algorithm. The MDN note above warns about that. The scaling multiple times is not happening and not a issue here -- the images are scaled and painted once. The current algorithm just makes sure the all pixels are used in scaling and destination image is painted as is without being rescaled (see mozCurrentTransformInverse usage).
Contains hi-res scanned image issue1597-page1. I don't think the algorithm is at fault here. Can we take this regression to close some major issues? Actually we already have this artifacts on color images as well. |
Also reported at https://bugzilla.mozilla.org/show_bug.cgi?id=759172 |
ctx.drawImage(tmpCanvas, 0, -h / heightScale); | ||
} else | ||
tmpCtx.putImageData(imgData, 0, 0); | ||
ctx.drawImage(tmpCanvas, 0, -h); |
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.
Missing brackets?
Yes. Thank you /botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/8b48372744eb010/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.21.233.14:8877/0dd33aac634dec3/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/8b48372744eb010/output.txt Total script time: 16.48 mins
Image differences available at: http://107.22.172.223:8877/8b48372744eb010/reftest-analyzer.xhtml#web=eq.log |
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/0dd33aac634dec3/output.txt Total script time: 24.98 mins
Image differences available at: http://107.21.233.14:8877/0dd33aac634dec3/reftest-analyzer.xhtml#web=eq.log |
/botio makeref |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @brendandahl received. Current queue size: 0 Live output at: http://107.22.172.223:8877/b135ccf1617014e/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_makeref from @brendandahl received. Current queue size: 0 Live output at: http://107.21.233.14:8877/b6ccd748bff5591/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/b135ccf1617014e/output.txt Total script time: 16.33 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/b6ccd748bff5591/output.txt Total script time: 24.80 mins
|
Type3 smoothing: pre-scale image in the paintImageMaskXObject
Forgot to note, doesn't look like it fixes #1416. |
Per MDN ( https://developer.mozilla.org/en/Canvas_tutorial/Using_images#drawImage_example_2 ):
"Images can become blurry when scaling up or grainy if they're scaled down too much. Scaling is probably best not done if you've got some text in it which needs to remain legible."
Using the simple algorithm to pre-scale the image.