Blurry image fix
See original GitHub issueRecently had an issue with images exporting and looking incredibly blurry.
Looking at the html2canvas logs I saw the x position and crop position were returning as 174.5. This half a pixel was causing the images to render with an excessive amount of blur.
To force this to stop (as I couldn’t think of a reason this would be the desired outcome) I have added Math.floor() to the top, bottom, right, left positions. (I did not have any issues with width and height.).
function getBounds (node) {
if (node.getBoundingClientRect) {
var clientRect = node.getBoundingClientRect();
var width = node.offsetWidth == null ? clientRect.width : node.offsetWidth;
return {
top : Math.floor(clientRect.top),
bottom: Math.floor(clientRect.bottom || (clientRect.top + clientRect.height)),
right : Math.floor(clientRect.left + width),
left : Math.floor(clientRect.left),
width : width,
height: node.offsetHeight == null ? clientRect.height : node.offsetHeight
};
}
return {};
}
Issue Analytics
- State:
- Created 8 years ago
- Reactions:15
- Comments:29 (3 by maintainers)
Top Results From Across the Web
Unblur Images: Free Online Image Deblurring Tool - Fotor
You can now fix blurry images in just one click with Fotor's image deblurring tool! Powered by artificial intelligence, Fotor will analyze and...
Read more >Sharpen image online - PineTools
Sharpen an image. ... Blurred frame images generator · Take a screenshot · Bulk add noise · Bulk blur image · Bulk blurred...
Read more >3 Easy Ways to Make Blurry Image Clear and Sharp
Blurry photos are an eyesore, and one of the fastest ways to fix them is with Let's Enhance. Its neural nets will sharpen...
Read more >How to Fix Blurry Pictures: 3 Ways - MakeUseOf
2. How to Fix Blurry Pictures With Fotor (Browser) · Go to the Fotor website, and from the Get a Quick Start tab,...
Read more >Unblur & Sharpen Image Online 100% Free - PicWish
How to sharpen image in PicWish Photo Editor? ... Upload a blurry photo file from your photo library. ... Reduce blurring automatically in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And after two years they don’t have found anything better ?? 👏
I used this and it fixed the issue
html2canvas(domElement, { scale: 2 });