Html2canvas: High quality image using Zoom

Created on 7 Apr 2016  路  5Comments  路  Source: niklasvh/html2canvas

I would like generate high quality image from DOM element. I tried to scale up element using css "zoom" by without success ;( zoom is not implemented?

Most helpful comment

@enjoytheday I scaled the dom, so we should make sure the user cannot see this scale. But here we can't set the dom to display:none, otherwise html2canvas will not working! So I set zIndex of the positioned dom to -1, it works!

  myDom.style.transform = myDom.style.webkitTransform = 'scale(2)'
  myDom.style.transformOrigin = myDom.style.webkitTransformOrigin = '0 0'
  html2canvas(myDom, {
    width: myDom.offsetWidth * 2,
    height: myDom.offsetHeight * 2
  }).then(function(canvas) {
    var data = canvas.toDataURL()    // now img quality doubled!
  })

All 5 comments

https://jsfiddle.net/enjoythedaycsk/9L966sdd/1/

I tried to achieve high resolution thing in this example but didn't get that...

Click on download pngx2 button..

Is it possible to do operations on backend like when button is clicked canvas turns into twice its size and then pic is captured and then again canvas is taken back to regular size..

I choose transform scale(2), not bad!
Wish html2canvas add an option(feature) like multiplier(zoom). 馃槂

can you please share your code so that we can see what result are you getting exactly

@enjoytheday I scaled the dom, so we should make sure the user cannot see this scale. But here we can't set the dom to display:none, otherwise html2canvas will not working! So I set zIndex of the positioned dom to -1, it works!

  myDom.style.transform = myDom.style.webkitTransform = 'scale(2)'
  myDom.style.transformOrigin = myDom.style.webkitTransformOrigin = '0 0'
  html2canvas(myDom, {
    width: myDom.offsetWidth * 2,
    height: myDom.offsetHeight * 2
  }).then(function(canvas) {
    var data = canvas.toDataURL()    // now img quality doubled!
  })

@luck2011 can you please set this this in jsfiddle example?

https://jsfiddle.net/enjoythedaycsk/9L966sdd/1/

I tried but its not being set by me.

You can edit it completely or can create new one.

It will be helpful to many :dancer:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tibewww picture tibewww  路  4Comments

yasergh picture yasergh  路  5Comments

stevencherry1 picture stevencherry1  路  3Comments

dking3876 picture dking3876  路  4Comments

deepender87 picture deepender87  路  4Comments