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

How to get better image quality? #1611

Open
corey34 opened this issue Jul 31, 2018 · 6 comments
Open

How to get better image quality? #1611

corey34 opened this issue Jul 31, 2018 · 6 comments

Comments

@corey34
Copy link

corey34 commented Jul 31, 2018

How do you get better image quality? The standard DPI seems to be 72 which is not good enough for my case. I have seen some reference to DPI as an option but it appears that it may have been removed on the current version?

I have also seen that the scale option, in combination with width and height options, being used and that works for web view but when saving the image on my computer it's not what I need.

Is there a way to export an image with a higher DPI?

Thanks

Specifications:

  • html2canvas version tested with: v1.0.0-alpha.12
@ffflabs
Copy link

ffflabs commented Jul 31, 2018

It depends on what kind of objects are you trying to capture, I guess.

However, you said the problem affects the downloaded image. How exactly are you downloading the image?

@corey34
Copy link
Author

corey34 commented Jul 31, 2018

Sorry, should have been more descriptive. I am exporting PNG images, made up of layered images. Some of those layered images are resized smaller with JQueryUI Resizeable (https://jqueryui.com/resizable/).

The saved image is a lower quality than what shows on display.

I am using Filesaver (https://github.com/eligrey/FileSaver.js) and just my mouse (right click, save as...). Both have the same outcome.

Thanks

@corey34
Copy link
Author

corey34 commented Aug 7, 2018

A little more information after using this more. It appears that most of the quality issues I am seeing are coming from images which source is much bigger than what is displayed on the screen. For example, the image may display as a 300x250 but the actual image is 1200x1000. The image looks good on the computer screen but after using html2canvas, the image loses quality. However, if the final image displays closer to it's source size of 1200x1000, then it looks great.

I'm new to how canvas's work so maybe that is a common issue and not actually related to html2canvas?

If this is unrelated to html2canvas, does anyone recommend a better way of doing this? Is there something I can use that would transform my image into a better quality image before using html2canvas?

Thanks

@corey34
Copy link
Author

corey34 commented Jan 13, 2019

@amenadiel, any thoughts on this? I've spent countless hours on this over the last few months and still cannot get this.

@selmalee
Copy link

@amenadiel, any thoughts on this? I've spent countless hours on this over the last few months and still cannot get this.

try html2canvas(dom, { scale: 2 })
It is mentioned in #1087

@KingAmo
Copy link

KingAmo commented May 12, 2022

use <img /> instead of background-image get better image quality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants