Scaling Images
the second variant of the drawImage method adds two new parameters and it allows us to place scaled images on the canvas.
drawImage(image, x, y, width, height)
Where width and height is the image’s size on the target canvas.
Example
<!DOCTYPE HTML> <html> <head> <title>Canvas tutorial</title> <script> function draw(){ var ctx = document.getElementById('canvas').getContext('2d'); var img = new Image(); img.onload = function(){ for (var i = 0; i < 4; i++) { for (var j = 0; j < 3; j++) { ctx.drawImage(img, j * 50, i * 38, 50, 38); } } }; img.src = '123.png'; } </script> </head> <body onload="draw();"> <canvas id="canvas" width="200" height="200"> </canvas> </body> </html>