Way to increase resolution of the image generated via toDataURL
See original GitHub issueThis is more of a feature request. I am easily able to generate the PNG by calling toDataURL
on the returned canvas
. But the quality of the image is rather blurry/poor. I did some googling & found out that by default it just returns an image at 96 dpi. And there doesnt seem to be a standard way of improving this. Also the toDataURLHD
is experimental and does not work any ways.
Is there any way html2canvas
can return an image at a higher resolution? Or even if it can provide a way to get the DOM being rendered, I can use some library that uses the DOM (with all the computed styles applied to it) and then generate whatever image I want.
Issue Analytics
- State:
- Created 10 years ago
- Reactions:2
- Comments:58 (6 by maintainers)
Top Results From Across the Web
Is there any way to increase resolution of the image generated ...
I am easily able to generate the PNG by calling toDataURL on the returned canvas. But the quality of the image is rather...
Read more >HTMLCanvasElement.toDataURL() - Web APIs | MDN
The HTMLCanvasElement.toDataURL() method returns a data URL containing a representation of the image in the format specified by the type ...
Read more >HTML5 Canvas Export to High Quality Image Tutorial - Konva
How to export a high quality image from a stage?If you need to export a stage as an image or as base64 then...
Read more >HTMLCanvasElement.toDataURL()
The HTMLCanvasElement.toDataURL() method returns a data URI containing a representation of the image in the format specified by the type ...
Read more >Generating Images Using HTML Canvas in JavaScript
The story image should be even simpler because we don't need to resize it. From here, you could use the toDataURL to add...
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
I figured out another way to get a high resolution image that doesn’t need to resize the body. However, it does have to absolutely position the source element due to a bug in html2canvas (#790, #820, #893, #922, etc). Based on @MisterLamb’s retina code.
Usage:
EDIT: Reduced hackiness using absolute positioning instead of actually moving the element and adjusting margins, thanks to @jason-o-matic for the suggestion.
+1 for this. Looking to get an image with html2canvas to insert into a PDF, but getting a blurry quality.