简体   繁体   English

iPad上的HTML2Canvas空白图像和笔记本电脑上的低质量图像

[英]HTML2Canvas blank image on iPad and very low quality images on laptops

Here is my code: 这是我的代码:

html2canvas($("#divImage"), {
        onrendered: function(canvas) {  
            console.log ("w: " + canvas.width + "h: " + canvas.height);  
            window.open(canvas.toDataURL()); 
        }
});  

This code gives me a very low resolution image using a laptop (chrome or safari) and gives me a blank image on the iPad. 这段代码为我提供了使用笔记本电脑(铬或野生动物园)的低分辨率图像,并在iPad上给了我空白图像。 The height and width that comes back in the console is 400x400px which is the size displayed on the page. 控制台中返回的高度和宽度为400x400px,即页面上显示的大小。 The image it self has 1000x1000px. 本身的图片有1000x1000px。 I've looked around and found some posts about it but none of had a solution. 我环顾四周,发现了一些有关它的帖子,但是都没有解决方案。 Thanks. 谢谢。

Have you tried setting its quality? 您是否尝试过设置其质量?

var fullQuality = canvas.toDataURL("image/jpeg", 1.0);
// data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...9oADAMBAAIRAxEAPwD/AD/6AP/Z"
var mediumQuality = canvas.toDataURL("image/jpeg", 0.5);
var lowQuality = canvas.toDataURL("image/jpeg", 0.1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM