Answers for "how to set the width and heigth of the canvas to be the same size as that of an image"

0

how to set the width and heigth of the canvas to be the same size as that of an image

function resizeCanvas()
{
    var img = document.getElementById('dynamic_img'); 
    var width = img.clientWidth;
    var height = img.clientHeight;

    var canvas = document.getElementById('canvas'); 
    canvas.style.width = width;
    canvas.style.height = height;
}
Posted by: Guest on February-03-2021
0

how to set the width and heigth of the canvas to be the same size as that of an image

<canvas id="canvas"><img src="dynamic_url" id="dynamic_img" /></canvas>
Posted by: Guest on February-03-2021

Code answers related to "how to set the width and heigth of the canvas to be the same size as that of an image"

Browse Popular Code Answers by Language