dongyi8383
2018-07-16 08:43
浏览 1.1k
已采纳

Html2canvas以高“SCALE”拍摄高质量的屏幕截图

I change the screenshot quality by change the scale, for high quality I use the high scale, it works for quality that the image size will be less than 15MB and for the higher quality it, not works, actually when the screenshot takes an image by more than 15 MB I can't do anything by that image data.

jQuery(document).ready(function($) {
  $('body').click(function(event) {
    html2canvas(document.getElementById("content"), {
      scale: 5.5,
    }).then(function(canvas) {
      // Export the canvas to its data URI representation
      var base64image = canvas.toDataURL("image/png");
      // console.log(base64image);
      $('.entry-content').after(`
        <img src="` + base64image + `" alt="">
      `);
    });
  });
});

图片转代码服务由CSDN问答提供 功能建议

我通过更改 scale 来更改屏幕截图质量,高质量我使用高 scale, it适用于质量,图像大小将小于 15MB ,对于更高的质量,它不起作用,实际上当截图拍摄的图像超过15 MB我不能做 任何由该图像数据。

  jQuery(document).ready(function($){
 $('body')。click(function(event){
  html2canvas(document.getElementById(“content”),{
 scale:5.5,
})。then(function(canvas){
 //将画布导出到其数据URI表示
 var base64image = canvas.toDataURL  (“image / png”); 
 // console.log(base64image); 
 $('。entry-content')。after(`
&lt; img src =“`+ base64image +`”alt =  “”&gt; 
`); 
}); 
}); 
}); 
   
 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douzai2562 2018-10-23 06:02
    已采纳

    I finally found the solution It is related to the php.ini setting I change PHP.ini configuration as bellow and know I can take screenshot up to 90 MB by increasing the scale value.

    post_max_size=1024M

    upload_max_filesize=2048M

    If not working please add these codes to functions.php file

    @ini_set('upload_max_size','256M');
    @ini_set('post_max_size','256M');
    @ini_set('max_execution_time','30000');
    @ini_set('memory_limit', '-1');
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题