Answers for "how to make canvas width and heigth equal to image with and height size in jaavscript"

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 make canvas width and heigth equal to image with and height size in jaavscript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language