HTML canvas drawImage() Method Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In HTML5, canvas drawImage() function is used to display an image or video on canvas. This function can be used to display the whole image or just a small part of the image. But, image has to be loaded first to load it further on canvas. Syntax: context.drawImage(img, x, y, swidth, sheight, sx, sy, width, height); Parameter Values: img: It indicates the image or video to draw on canvas.x: It indicates the x-coordinate where image has to be placed.y: It indicates the y-coordinate where image has to be placed.swidth: It is optional parameter and indicates the width of the clipped image.sheight: It is optional parameter and indicates the height of the clipped image.sx: It is optional parameter and indicates x-coordinate where to start the clipping.sy: It is optional parameter and indicates y-coordinate where to start the clipping.width: It is optional parameter and indicates the width of the image to use.height: It is optional parameter and indicates the height of the image to use. Example: HTML <!DOCTYPE html> <html> <head> <title> HTML | canvas drawImage() Method </title> </head> <body> <p>Image:</p> <img id="GFG" width="480" height="240" src="canvas drawImage.png" alt="The Scream" /> <p>Canvas:</p> <canvas id="myGFGCanvas" width="520" height="300" style="border: 1px solid #d3d3d3;"> Your browser is not supported for HTML5 canvas tag. </canvas> <script> window.onload = function () { var c = document.getElementById("myGFGCanvas"); var ctx = c.getContext("2d"); var img = document.getElementById("GFG"); ctx.drawImage(img, 20, 20); }; </script> </body> </html> Output: Comment U utkarsh_kumar Follow 0 Improve U utkarsh_kumar Follow 0 Improve Article Tags : Web Technologies HTML HTML5 HTML-Methods Explore HTML BasicsHTML Introduction5 min readHTML Editors5 min readHTML Basics7 min readStructure & ElementsHTML Elements5 min readHTML Attributes8 min readHTML Headings4 min readHTML Paragraphs5 min readHTML Text Formatting4 min readHTML Block and Inline Elements3 min readHTML Charsets4 min readListsHTML Lists3 min readHTML Ordered Lists5 min readHTML Unordered Lists4 min readHTML Description Lists3 min readVisuals & MediaHTML Colors11 min readHTML Links Hyperlinks3 min readHTML Images7 min readHTML Favicon4 min readHTML Video4 min readLayouts & DesignsHTML Tables10 min readHTML Iframes4 min readHTML Layout4 min readHTML File Paths3 min readProjects & Advanced TopicsHTML Forms5 min readHTML5 Semantics6 min readHTML URL Encoding4 min readHTML Responsive Web Design11 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readTutorial ReferencesHTML Tags - A to Z List15+ min readHTML Attributes Complete Reference8 min readHTML Global Attributes5 min readHTML5 Complete Reference8 min readHTML5 MathML Complete Reference3 min readHTML DOM Complete Reference15+ min readHTML DOM Audio/Video Complete Reference2 min readSVG Element Complete Reference5 min readSVG Attribute Complete Reference8 min readSVG Property Complete Reference7 min readHTML Canvas Complete Reference4 min read Like