There is a canvas, which I set the size

<canvas id='my_canvas' height=300px width=400px>Reload page</canvas> 

After that I upload a picture into it and crop it (I do not quite cut it, but I display a part)

 ctx.drawImage(pic,position,0,size,size,0,0,size,size); 

How can I resize the canvas after "trimming" the image? If you prescribe through the code, nothing changes

 canvas.width=position; canvas.height=position; 

Thank!

    1 answer 1

    Try this:

     canvas.width = 500; canvas.height = 400; canvas.style.width = '1000px'; canvas.style.height = '800px'; 
    • thanks a lot, helped - Oloji