I am writing a small snippet that allows a user to drag an image into a div container (dropzone) and then creates a canvas in that div and paints the image into the div. But
I have canvas width and heihgt set to 100% in css setting so:
canvas.width = canvas.offsetWidth; canvas.height = canvas.offsetHeight;
in page load event do the trick